Update TDengine CodeFirst

This commit is contained in:
sunkaixuan
2023-10-01 20:16:01 +08:00
parent d318e67f0d
commit 7896b00dc1
2 changed files with 28 additions and 5 deletions

View File

@@ -119,7 +119,7 @@ namespace SqlSugar.TDengine
public override void NoExistLogic(EntityInfo entityInfo) public override void NoExistLogic(EntityInfo entityInfo)
{ {
List<DbColumnInfo> dbColumns = new List<DbColumnInfo>(); List<DbColumnInfo> dbColumns = new List<DbColumnInfo>();
foreach (var item in entityInfo.Columns.OrderBy(it=>it.UnderType==typeof(DateTime)?0:1)) foreach (var item in entityInfo.Columns.Where(it=>it.PropertyName!= "TagsTypeId").OrderBy(it=>it.UnderType==typeof(DateTime)?0:1))
{ {
var addItem = EntityColumnToDbColumn(entityInfo, entityInfo.DbTableName, item); var addItem = EntityColumnToDbColumn(entityInfo, entityInfo.DbTableName, item);
dbColumns.Add(addItem); dbColumns.Add(addItem);
@@ -160,6 +160,12 @@ namespace SqlSugar.TDengine
return "FLOAT"; return "FLOAT";
case "int": case "int":
return "INT"; return "INT";
case "int32":
return "INT";
case "int16":
return "INT";
case "int64":
return "BIGINT";
case "uint": case "uint":
return "INT UNSIGNED"; return "INT UNSIGNED";
case "long": case "long":

View File

@@ -88,7 +88,7 @@ namespace SqlSugar.TDengine
{ {
get get
{ {
return "CREATE STABLE IF NOT EXISTS {0}(\r\n{1} ) TAGS(TagsTypeId VARCHAR(20))"; return "CREATE STABLE IF NOT EXISTS {0}(\r\n{1} ) TAGS("+SqlBuilder.GetTranslationColumnName("TagsTypeId") +" VARCHAR(20))";
} }
} }
protected override string CreateTableColumn protected override string CreateTableColumn
@@ -193,14 +193,14 @@ namespace SqlSugar.TDengine
{ {
get get
{ {
return "DEFAULT NULL"; return " ";
} }
} }
protected override string CreateTableNotNull protected override string CreateTableNotNull
{ {
get get
{ {
return "NOT NULL"; return " ";
} }
} }
protected override string CreateTablePirmaryKey protected override string CreateTablePirmaryKey
@@ -220,6 +220,23 @@ namespace SqlSugar.TDengine
#endregion #endregion
#region Methods #region Methods
public override bool AddColumn(string tableName, DbColumnInfo columnInfo)
{
if (columnInfo.DbColumnName == "TagsTypeId")
{
return true;
}
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
var isAddNotNUll = columnInfo.IsNullable == false && columnInfo.DefaultValue.HasValue();
if (isAddNotNUll)
{
columnInfo = this.Context.Utilities.TranslateCopy(columnInfo);
columnInfo.IsNullable = true;
}
string sql = GetAddColumnSql(tableName, columnInfo);
this.Context.Ado.ExecuteCommand(sql);
return true;
}
public override List<DbTableInfo> GetViewInfoList(bool isCache = true) public override List<DbTableInfo> GetViewInfoList(bool isCache = true)
{ {
return new List<DbTableInfo>(); return new List<DbTableInfo>();