mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Synchronization code
This commit is contained in:
parent
04e31fc4df
commit
7ca313d842
@ -653,11 +653,19 @@ WHERE upper(t.TABLE_NAME) = upper('{tableName}')
|
|||||||
private static void ConvertCreateColumnInfo(DbColumnInfo x)
|
private static void ConvertCreateColumnInfo(DbColumnInfo x)
|
||||||
{
|
{
|
||||||
string[] array = new string[] { "int" };
|
string[] array = new string[] { "int" };
|
||||||
|
if (x.OracleDataType.HasValue())
|
||||||
|
{
|
||||||
|
x.DataType = x.OracleDataType;
|
||||||
|
}
|
||||||
if (array.Contains(x.DataType?.ToLower()))
|
if (array.Contains(x.DataType?.ToLower()))
|
||||||
{
|
{
|
||||||
x.Length = 0;
|
x.Length = 0;
|
||||||
x.DecimalDigits = 0;
|
x.DecimalDigits = 0;
|
||||||
}
|
}
|
||||||
|
if (x.DecimalDigits > 0 && x.DataType?.ToLower()?.IsIn("varchar", "clob", "varchar2", "nvarchar2", "nvarchar") == true)
|
||||||
|
{
|
||||||
|
x.DecimalDigits = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,14 @@ namespace SqlSugar
|
|||||||
var updateTable = string.Format("UPDATE {0} SET", base.GetTableNameStringNoWith);
|
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 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();
|
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>();
|
List<string> whereList = new List<string>();
|
||||||
foreach (var item in pkList)
|
foreach (var item in pkList)
|
||||||
{
|
{
|
||||||
|
@ -84,9 +84,15 @@ namespace SqlSugar
|
|||||||
cast(obj_description(relfilenode,'pg_class') as varchar) as Description from pg_class c
|
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";
|
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
|
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";
|
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
|
protected override string GetViewInfoListSql
|
||||||
|
@ -163,7 +163,11 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
if (IsSqlServerModel())
|
if (IsSqlServerModel())
|
||||||
{
|
{
|
||||||
if (dbType == "varchar")
|
if (dbType == "numeric")
|
||||||
|
{
|
||||||
|
dbType = "numeric(18,6)";
|
||||||
|
}
|
||||||
|
else if (dbType == "varchar")
|
||||||
{
|
{
|
||||||
dbType = "varchar(max)";
|
dbType = "varchar(max)";
|
||||||
}
|
}
|
||||||
|
@ -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)
|
public override string FormatDateTimeOffset(object value)
|
||||||
{
|
{
|
||||||
return "'" + ((DateTimeOffset)value).ToString("o") + "'";
|
return "'" + ((DateTimeOffset)value).ToString("o") + "'";
|
||||||
|
Loading…
Reference in New Issue
Block a user