Synchronization code

This commit is contained in:
sunkaixuan 2025-03-28 16:53:35 +08:00
parent 04e31fc4df
commit 7ca313d842
5 changed files with 85 additions and 2 deletions

View File

@ -653,11 +653,19 @@ WHERE upper(t.TABLE_NAME) = upper('{tableName}')
private static void ConvertCreateColumnInfo(DbColumnInfo x)
{
string[] array = new string[] { "int" };
if (x.OracleDataType.HasValue())
{
x.DataType = x.OracleDataType;
}
if (array.Contains(x.DataType?.ToLower()))
{
x.Length = 0;
x.DecimalDigits = 0;
}
if (x.DecimalDigits > 0 && x.DataType?.ToLower()?.IsIn("varchar", "clob", "varchar2", "nvarchar2", "nvarchar") == true)
{
x.DecimalDigits = 0;
}
}
#endregion
}

View File

@ -28,6 +28,14 @@ namespace SqlSugar
var updateTable = string.Format("UPDATE {0} SET", base.GetTableNameStringNoWith);
var setValues = string.Join(",", t.Where(s => !s.IsPrimarykey).Where(s => OldPrimaryKeys == null || !OldPrimaryKeys.Contains(s.DbColumnName)).Select(m => GetOracleUpdateColums(i, m)).ToArray());
var pkList = t.Where(s => s.IsPrimarykey).ToList();
if (this.IsWhereColumns && this.PrimaryKeys?.Any() == true)
{
var whereColumns = pkList.Where(it => this.PrimaryKeys?.Any(p => p.EqualCase(it.PropertyName) || p.EqualCase(it.DbColumnName)) == true).ToList();
if (whereColumns.Any())
{
pkList = whereColumns;
}
}
List<string> whereList = new List<string>();
foreach (var item in pkList)
{

View File

@ -84,9 +84,15 @@ namespace SqlSugar
cast(obj_description(relfilenode,'pg_class') as varchar) as Description from pg_class c
where relkind = 'r' and c.oid >= 16384 and c.relnamespace != 99 and c.relname not like '%pl_profiler_saved%' order by relname";
}
return @"select cast(relname as varchar) as Name,
var result= @"select cast(relname as varchar) as Name,
cast(obj_description(relfilenode,'pg_class') as varchar) as Description from sys_class c
where relkind = 'r' and c.oid >= 16384 and c.relnamespace != 99 and c.relname not like '%pl_profiler_saved%' order by relname";
if (IsSqlServerModel())
{
result = result.Replace(" as varchar)", " as varchar(max))");
}
return result;
}
}
protected override string GetViewInfoListSql

View File

@ -163,7 +163,11 @@ namespace SqlSugar
}
if (IsSqlServerModel())
{
if (dbType == "varchar")
if (dbType == "numeric")
{
dbType = "numeric(18,6)";
}
else if (dbType == "varchar")
{
dbType = "varchar(max)";
}

View File

@ -178,6 +178,63 @@ namespace SqlSugar
}
}
}
public override object FormatValue(object value)
{
var N = string.Empty;
if (value == null)
{
return "NULL";
}
else
{
var type = UtilMethods.GetUnderType(value.GetType());
if (type == UtilConstants.DateType)
{
var date = value.ObjToDate();
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
{
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
}
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
}
else if (type == UtilConstants.ByteArrayType)
{
string bytesString = "0x" + BitConverter.ToString((byte[])value).Replace("-", "");
return bytesString;
}
else if (type.IsEnum())
{
if (this.Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true)
{
return value.ToSqlValue();
}
else
{
return Convert.ToInt64(value);
}
}
else if (type == UtilConstants.BoolType)
{
return value.ObjToBool() ? "1" : "0";
}
else if (type == UtilConstants.StringType || type == UtilConstants.ObjType)
{
return N + "'" + value.ToString().ToSqlFilter() + "'";
}
else if (type == UtilConstants.DateTimeOffsetType)
{
return FormatDateTimeOffset(value);
}
else if (type == UtilConstants.FloatType)
{
return N + "'" + Convert.ToDouble(value).ToString() + "'";
}
else
{
return N + "'" + value.ToString() + "'";
}
}
}
public override string FormatDateTimeOffset(object value)
{
return "'" + ((DateTimeOffset)value).ToString("o") + "'";