Update ClickHouse

This commit is contained in:
sunkaixuan 2022-08-14 02:18:50 +08:00
parent 83f6d88fa9
commit daed5082b1

View File

@ -253,10 +253,14 @@ namespace SqlSugar.ClickHouse
{
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
var columnName= this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName);
string sql = GetUpdateColumnSql(tableName, columnInfo);
this.Context.Ado.ExecuteCommand(sql);
var isnull = columnInfo.IsNullable?" DROP NOT NULL ": " SET NOT NULL ";
this.Context.Ado.ExecuteCommand(string.Format("alter table {0} alter {1} {2}",tableName,columnName, isnull));
if (columnInfo.IsNullable)
{
if (!columnInfo.DataType.ObjToString().ToLower().Contains("nullable"))
{
columnInfo.DataType = $"Nullable({columnInfo.DataType})";
}
}
this.Context.Ado.ExecuteCommand(string.Format("ALTER TABLE {0} MODIFY COLUMN {1} {2} ", tableName,columnName,columnInfo.DataType));
return true;
}