Update pgsql

This commit is contained in:
sunkaixuan 2024-04-26 21:26:17 +08:00
parent 8133885088
commit 2b542cf53d

View File

@ -338,9 +338,34 @@ namespace SqlSugar
}
var dt = new Dictionary<string, object>();
dt.Add(columnInfo.DbColumnName, value);
this.Context.Updateable(dt)
.AS(tableName)
.Where($"{this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName)} is null ").ExecuteCommand();
if (columnInfo.DataType.EqualCase("json") && columnInfo.DefaultValue?.Contains("}") == true)
{
{
dt[columnInfo.DbColumnName] = "{}";
var sqlobj = this.Context.Updateable(dt)
.AS(tableName)
.Where($"{this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName)} is null ").ToSql();
sqlobj.Value[0].IsJson = true;
this.Context.Ado.ExecuteCommand(sqlobj.Key, sqlobj.Value);
}
}
else if (columnInfo.DataType.EqualCase("json") && columnInfo.DefaultValue?.Contains("}") == true)
{
{
dt[columnInfo.DbColumnName] = "[]";
var sqlobj = this.Context.Updateable(dt)
.AS(tableName)
.Where($"{this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName)} is null ").ToSql();
sqlobj.Value[0].IsJson = true;
this.Context.Ado.ExecuteCommand(sqlobj.Key, sqlobj.Value);
}
}
else
{
this.Context.Updateable(dt)
.AS(tableName)
.Where($"{this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName)} is null ").ExecuteCommand();
}
columnInfo.IsNullable = false;
UpdateColumn(tableName, columnInfo);
}