Add float/double data types

This commit is contained in:
MarioE 2013-11-27 22:00:47 -05:00
parent 234e203eb3
commit 8b7e8772da

View file

@ -57,14 +57,16 @@ namespace TShockAPI.DB
private static readonly Dictionary<MySqlDbType, string> TypesAsStrings = new Dictionary<MySqlDbType, string> private static readonly Dictionary<MySqlDbType, string> TypesAsStrings = new Dictionary<MySqlDbType, string>
{ {
{MySqlDbType.VarChar, "TEXT"}, { MySqlDbType.VarChar, "TEXT" },
{MySqlDbType.String, "TEXT"}, { MySqlDbType.String, "TEXT" },
{MySqlDbType.Text, "TEXT"}, { MySqlDbType.Text, "TEXT" },
{MySqlDbType.TinyText, "TEXT"}, { MySqlDbType.TinyText, "TEXT" },
{MySqlDbType.MediumText, "TEXT"}, { MySqlDbType.MediumText, "TEXT" },
{MySqlDbType.LongText, "TEXT"}, { MySqlDbType.LongText, "TEXT" },
{MySqlDbType.Int32, "INTEGER"}, { MySqlDbType.Float, "REAL" },
{MySqlDbType.Blob, "BLOB"}, { MySqlDbType.Double, "REAL" },
{ MySqlDbType.Int32, "INTEGER" },
{ MySqlDbType.Blob, "BLOB" },
}; };
public string DbTypeToString(MySqlDbType type, int? length) public string DbTypeToString(MySqlDbType type, int? length)
@ -72,7 +74,7 @@ namespace TShockAPI.DB
string ret; string ret;
if (TypesAsStrings.TryGetValue(type, out ret)) if (TypesAsStrings.TryGetValue(type, out ret))
return ret; return ret;
throw new NotImplementedException(Enum.GetName(typeof (MySqlDbType), type)); throw new NotImplementedException(Enum.GetName(typeof(MySqlDbType), type));
} }
protected override string EscapeTableName(string table) protected override string EscapeTableName(string table)
@ -104,21 +106,23 @@ namespace TShockAPI.DB
private static readonly Dictionary<MySqlDbType, string> TypesAsStrings = new Dictionary<MySqlDbType, string> private static readonly Dictionary<MySqlDbType, string> TypesAsStrings = new Dictionary<MySqlDbType, string>
{ {
{MySqlDbType.VarChar, "VARCHAR"}, { MySqlDbType.VarChar, "VARCHAR" },
{MySqlDbType.String, "CHAR"}, { MySqlDbType.String, "CHAR" },
{MySqlDbType.Text, "TEXT"}, { MySqlDbType.Text, "TEXT" },
{MySqlDbType.TinyText, "TINYTEXT"}, { MySqlDbType.TinyText, "TINYTEXT" },
{MySqlDbType.MediumText, "MEDIUMTEXT"}, { MySqlDbType.MediumText, "MEDIUMTEXT" },
{MySqlDbType.LongText, "LONGTEXT"}, { MySqlDbType.LongText, "LONGTEXT" },
{MySqlDbType.Int32, "INT"}, { MySqlDbType.Float, "FLOAT" },
{ MySqlDbType.Double, "DOUBLE" },
{ MySqlDbType.Int32, "INT" },
}; };
public string DbTypeToString(MySqlDbType type, int? length) public string DbTypeToString(MySqlDbType type, int? length)
{ {
string ret; string ret;
if (TypesAsStrings.TryGetValue(type, out ret)) if (TypesAsStrings.TryGetValue(type, out ret))
return ret + (length != null ? "({0})".SFormat((int) length) : ""); return ret + (length != null ? "({0})".SFormat((int)length) : "");
throw new NotImplementedException(Enum.GetName(typeof (MySqlDbType), type)); throw new NotImplementedException(Enum.GetName(typeof(MySqlDbType), type));
} }
protected override string EscapeTableName(string table) protected override string EscapeTableName(string table)