Synchronization code

This commit is contained in:
sunkaixuan
2025-02-14 12:51:24 +08:00
parent 63044b8564
commit 301f58dfdb
2 changed files with 33 additions and 3 deletions

View File

@@ -113,13 +113,17 @@ namespace SqlSugar
{
get
{
if (IsSqlServerModel())
{
return "ALTER TABLE {0} ADD {1} {2}{3} {4} {5} {6}";
}
return "ALTER TABLE {0} ADD COLUMN {1} {2}{3} {4} {5} {6}";
}
}
protected override string AlterColumnToTableSql
{
get
{
{
return "alter table {0} ALTER COLUMN {1} {2}{3} {4} {5} {6}";
}
}
@@ -369,6 +373,15 @@ WHERE tgrelid = '" + tableName + "'::regclass");
}
public override bool UpdateColumn(string tableName, DbColumnInfo columnInfo)
{
if (IsSqlServerModel())
{
if (columnInfo.DataType.EqualCase("uuid"))
{
columnInfo.DataType = "uniqueidentifier";
columnInfo.Length = 0;
columnInfo.Scale = 0;
}
}
ConvertCreateColumnInfo(columnInfo);
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
@@ -485,6 +498,19 @@ WHERE tgrelid = '" + tableName + "'::regclass");
}
return true;
}
public override bool AddColumn(string tableName, DbColumnInfo columnInfo)
{
if (IsSqlServerModel())
{
if (columnInfo.DataType.EqualCase("uuid"))
{
columnInfo.DataType = "uniqueidentifier";
columnInfo.Length = 0;
columnInfo.Scale = 0;
}
}
return base.AddColumn(tableName, columnInfo);
}
public override bool RenameTable(string oldTableName, string newTableName)
{
return base.RenameTable(this.SqlBuilder.GetTranslationTableName(oldTableName), this.SqlBuilder.GetTranslationTableName(newTableName));

View File

@@ -182,9 +182,9 @@ namespace SqlSugar
}
public override string DateValue(MethodCallExpressionModel model)
{
if (IsSqlServerModel(model))
if (IsSqlServerModel(model))
{
return base.DateValue(model);
return new SqlServerMethod().DateValue(model);
}
var parameter = model.Args[0];
var parameter2 = model.Args[1];
@@ -404,6 +404,10 @@ namespace SqlSugar
public override string MergeString(params string[] strings)
{
var key = Guid.NewGuid() + "";
if (strings.Length == 1)
{
return " pg_catalog.concat(" + string.Join(",", strings.Select(it => it?.Replace("+", key))).Replace("+", "").Replace(key, "+") + ",null) ";
}
return " pg_catalog.concat(" + string.Join(",", strings.Select(it => it?.Replace("+", key))).Replace("+", "").Replace(key, "+") + ") ";
}
public override string IsNull(MethodCallExpressionModel model)