Update TDengine

This commit is contained in:
sunkaixuan 2023-11-10 14:16:42 +08:00
parent 3a22318eb3
commit 4ec8dcdbb1
3 changed files with 19 additions and 3 deletions

View File

@ -6,7 +6,13 @@ namespace SqlSugar.TDengine
{
public class STable
{
[SugarColumn(IsOnlyIgnoreInsert =true ,IsOnlyIgnoreUpdate =true)]
public string TagsTypeId { get; set; }
[SugarColumn(IsOnlyIgnoreInsert = true, IsOnlyIgnoreUpdate = true)]
public string TagsTypeId { get; set; }
public static List<ColumnTagInfo> Tags = null;
}
public class ColumnTagInfo
{
public string Name { get; set; }
public string Value { get; set; }
}
}

View File

@ -9,7 +9,7 @@
<projectUrl>https://github.com/sunkaixuan/SqlSugar</projectUrl>
<iconUrl>https://secure.gravatar.com/avatar/a82c03402497b2e58fd65038a3699b30</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description> SqlSugar TDengine 核心库 </description>
<description> SqlSugar TDengine 核心库 ,DEMO用例 https://github.com/DotNetNext/SqlSugar </description>
<copyright>Copyright 2016</copyright>
<tags>TDengine Tdengine tdengine</tags>
<dependencies>

View File

@ -414,8 +414,18 @@ namespace SqlSugar.TDengine
string tableString = string.Format(this.CreateTableSql, this.SqlBuilder.GetTranslationTableName("STable_"+tableName.ToLower(isAutoToLowerCodeFirst)), string.Join(",\r\n", columnArray));
var childTableName = this.SqlBuilder.GetTranslationTableName(tableName.ToLower(isAutoToLowerCodeFirst));
var stableName = this.SqlBuilder.GetTranslationTableName("STable_"+tableName.ToLower(isAutoToLowerCodeFirst));
if (STable.Tags?.Any() == true)
{
var colums = STable.Tags.Select(it => this.SqlBuilder.GetTranslationTableName(it.Name)+ " VARCHAR(20) ");
tableString=tableString.Replace(SqlBuilder.GetTranslationColumnName("TagsTypeId"), string.Join(",", colums)); ;
}
this.Context.Ado.ExecuteCommand(tableString);
var createChildSql = $"CREATE TABLE IF NOT EXISTS {childTableName} USING {stableName} TAGS('default')";
if (STable.Tags?.Any() == true)
{
var colums = STable.Tags.Select(it => it.Value.ToSqlValue());
createChildSql = tableString.Replace("TAGS('default')", $"TAGS({string.Join(",", colums)})"); ;
}
this.Context.Ado.ExecuteCommand(createChildSql);
return tableString;
}