Browse Source

Synchronization code

pull/29/head
sunkaixuan 2 years ago
parent
commit
8f05892270
  1. 1
      Src/Asp.NetCore2/SqlSugar/Entities/ConnMoreSettings.cs
  2. 33
      Src/Asp.NetCore2/SqlSugar/Realization/Dm/DbMaintenance/DmDbMaintenance.cs
  3. 20
      Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmBuilder.cs
  4. 20
      Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmExpressionContext.cs
  5. 17
      Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs
  6. 31
      Src/Asp.NetCore2/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs
  7. 22
      Src/Asp.NetCore2/SqlSugar/Realization/Oracle/SqlBuilder/OracleBuilder.cs
  8. 20
      Src/Asp.NetCore2/SqlSugar/Realization/Oracle/SqlBuilder/OracleExpressionContext.cs
  9. 19
      Src/Asp.NetCore2/SqlSugar/Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs
  10. 8
      Src/Asp.NetCore2/SqlSugar/Realization/PostgreSQL/PostgreSQLProvider.cs
  11. 6
      Src/Asp.NetCore2/SqlSugar/Utilities/DbExtensions.cs
  12. 3
      Src/Asp.NetCore2/SqlSugar/Utilities/UtilMethods.cs

1
Src/Asp.NetCore2/SqlSugar/Entities/ConnMoreSettings.cs

@ -14,6 +14,7 @@ namespace SqlSugar
public bool DisableMillisecond { get; set; }
public bool PgSqlIsAutoToLower = true;
public bool PgSqlIsAutoToLowerCodeFirst = true;
public bool IsAutoToUpper = true;
public int DefaultCacheDurationInSeconds { get; set; }
public bool? TableEnumIsString { get; set; }
public DateTime? DbMinDate { get; set; } = Convert.ToDateTime("1900-01-01");

33
Src/Asp.NetCore2/SqlSugar/Realization/Dm/DbMaintenance/DmDbMaintenance.cs

@ -314,14 +314,14 @@ namespace SqlSugar
if (item.ColumnDescription != null)
{
//column remak
if (db.DbMaintenance.IsAnyColumnRemark(item.DbColumnName.ToUpper(), item.DbTableName.ToUpper()))
if (db.DbMaintenance.IsAnyColumnRemark(item.DbColumnName.ToUpper(IsUppper), item.DbTableName.ToUpper(IsUppper)))
{
db.DbMaintenance.DeleteColumnRemark(item.DbColumnName.ToUpper(), item.DbTableName.ToUpper());
db.DbMaintenance.AddColumnRemark(item.DbColumnName.ToUpper(), item.DbTableName.ToUpper(), item.ColumnDescription);
db.DbMaintenance.DeleteColumnRemark(item.DbColumnName.ToUpper(IsUppper), item.DbTableName.ToUpper(IsUppper));
db.DbMaintenance.AddColumnRemark(item.DbColumnName.ToUpper(IsUppper), item.DbTableName.ToUpper(IsUppper), item.ColumnDescription);
}
else
{
db.DbMaintenance.AddColumnRemark(item.DbColumnName.ToUpper(), item.DbTableName.ToUpper(), item.ColumnDescription);
db.DbMaintenance.AddColumnRemark(item.DbColumnName.ToUpper(IsUppper), item.DbTableName.ToUpper(IsUppper), item.ColumnDescription);
}
}
}
@ -398,7 +398,7 @@ namespace SqlSugar
this.Context.Ado.IsEnableLogEvent = false;
string sql = @" select distinct cu.COLUMN_name KEYNAME from user_cons_columns cu, user_constraints au
where cu.constraint_name = au.constraint_name
and au.constraint_type = 'P' and au.table_name = '" + tableName.ToUpper() + @"'";
and au.constraint_type = 'P' and au.table_name = '" + tableName.ToUpper(IsUppper) + @"'";
var pks = this.Context.Ado.SqlQuery<string>(sql);
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
return pks;
@ -414,7 +414,7 @@ namespace SqlSugar
string sql = "SELECT COMMENTS FROM USER_TAB_COMMENTS WHERE TABLE_NAME =@tableName ORDER BY TABLE_NAME";
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
this.Context.Ado.IsEnableLogEvent = false;
var pks = this.Context.Ado.SqlQuery<string>(sql, new { tableName = tableName.ToUpper() });
var pks = this.Context.Ado.SqlQuery<string>(sql, new { tableName = tableName.ToUpper(IsUppper) });
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
return pks;
});
@ -427,7 +427,7 @@ namespace SqlSugar
var comments = this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
() =>
{
string sql = "SELECT TVNAME AS TableName, COLNAME as DbColumnName ,COMMENT$ AS ColumnDescription from SYSCOLUMNCOMMENTS WHERE TVNAME='" + tableName.ToUpper() + "' ORDER BY TVNAME";
string sql = "SELECT TVNAME AS TableName, COLNAME as DbColumnName ,COMMENT$ AS ColumnDescription from SYSCOLUMNCOMMENTS WHERE TVNAME='" + tableName.ToUpper(IsUppper) + "' ORDER BY TVNAME";
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
this.Context.Ado.IsEnableLogEvent = false;
var pks = this.Context.Ado.SqlQuery<DbColumnInfo>(sql);
@ -462,7 +462,7 @@ namespace SqlSugar
//string primaryKeyInfo = null;
if (columns.Any(it => it.IsPrimarykey) && isCreatePrimaryKey)
{
sql= sql.TrimEnd(')')+ string.Format(", Primary key({0})", string.Join(",", columns.Where(it => it.IsPrimarykey).Select(it => this.SqlBuilder.GetTranslationColumnName(it.DbColumnName.ToLower()))));
sql= sql.TrimEnd(')')+ string.Format(", Primary key({0})", string.Join(",", columns.Where(it => it.IsPrimarykey).Select(it => this.SqlBuilder.GetTranslationColumnName(it.DbColumnName.ToUpper(IsUppper)))));
sql = sql + ")";
}
//sql = sql.Replace("$PrimaryKey", primaryKeyInfo);
@ -470,5 +470,22 @@ namespace SqlSugar
return true;
}
#endregion
#region Helper
public bool IsUppper
{
get
{
if (this.Context.CurrentConnectionConfig.MoreSettings == null)
{
return true;
}
else
{
return this.Context.CurrentConnectionConfig.MoreSettings.IsAutoToUpper == true;
}
}
}
#endregion
}
}

20
Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmBuilder.cs

@ -35,17 +35,31 @@ namespace SqlSugar
if (result.Contains("(") && result.Contains(")"))
return result;
else
return result.ToUpper();
return result.ToUpper(IsUppper);
}
public override string GetTranslationColumnName(string entityName, string propertyName)
{
var result = base.GetTranslationColumnName(entityName, propertyName);
return result.ToUpper();
return result.ToUpper(IsUppper);
}
public override string GetTranslationColumnName(string propertyName)
{
var result = base.GetTranslationColumnName(propertyName);
return result.ToUpper();
return result.ToUpper(IsUppper);
}
public bool IsUppper
{
get
{
if (this.Context.CurrentConnectionConfig.MoreSettings == null)
{
return true;
}
else
{
return this.Context.CurrentConnectionConfig.MoreSettings.IsAutoToUpper == true;
}
}
}
}
}

20
Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmExpressionContext.cs

@ -27,15 +27,29 @@ namespace SqlSugar
public override string SqlTranslationRight { get { return "\""; } }
public override string GetTranslationTableName(string entityName, bool isMapping = true)
{
return base.GetTranslationTableName(entityName, isMapping).ToUpper();
return base.GetTranslationTableName(entityName, isMapping).ToUpper(IsUppper);
}
public override string GetTranslationColumnName(string columnName)
{
return base.GetTranslationColumnName(columnName).ToUpper();
return base.GetTranslationColumnName(columnName).ToUpper(IsUppper);
}
public override string GetDbColumnName(string entityName, string propertyName)
{
return base.GetDbColumnName(entityName, propertyName).ToUpper();
return base.GetDbColumnName(entityName, propertyName).ToUpper(IsUppper);
}
public bool IsUppper
{
get
{
if (this.SugarContext?.Context?.Context?.CurrentConnectionConfig?.MoreSettings==null)
{
return true;
}
else
{
return this.SugarContext?.Context?.Context?.CurrentConnectionConfig?.MoreSettings.IsAutoToUpper == true;
}
}
}
}
public partial class DmMethod : DefaultDbMethod, IDbMethods

17
Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs

@ -37,9 +37,22 @@ namespace SqlSugar
private string GetOracleUpdateColums(int i, DbColumnInfo m)
{
return string.Format("\"{0}\"={1}", m.DbColumnName.ToUpper(), FormatValue(i, m.DbColumnName, m.Value));
return string.Format("\"{0}\"={1}", m.DbColumnName.ToUpper(IsUppper), FormatValue(i, m.DbColumnName, m.Value));
}
public bool IsUppper
{
get
{
if (this.Context.CurrentConnectionConfig.MoreSettings == null)
{
return true;
}
else
{
return this.Context.CurrentConnectionConfig.MoreSettings.IsAutoToUpper == true;
}
}
}
public object FormatValue(int i, string name, object value)
{
if (value == null)

31
Src/Asp.NetCore2/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs

@ -323,14 +323,14 @@ namespace SqlSugar
if (item.ColumnDescription != null)
{
//column remak
if (db.DbMaintenance.IsAnyColumnRemark(item.DbColumnName.ToUpper(), item.DbTableName.ToUpper()))
if (db.DbMaintenance.IsAnyColumnRemark(item.DbColumnName.ToUpper(IsUppper), item.DbTableName.ToUpper(IsUppper)))
{
db.DbMaintenance.DeleteColumnRemark(this.SqlBuilder.GetTranslationColumnName(item.DbColumnName) , item.DbTableName.ToUpper());
db.DbMaintenance.AddColumnRemark(this.SqlBuilder.GetTranslationColumnName(item.DbColumnName), item.DbTableName.ToUpper(), item.ColumnDescription);
db.DbMaintenance.DeleteColumnRemark(this.SqlBuilder.GetTranslationColumnName(item.DbColumnName) , item.DbTableName.ToUpper(IsUppper));
db.DbMaintenance.AddColumnRemark(this.SqlBuilder.GetTranslationColumnName(item.DbColumnName), item.DbTableName.ToUpper(IsUppper), item.ColumnDescription);
}
else
{
db.DbMaintenance.AddColumnRemark(item.DbColumnName.ToUpper(), item.DbTableName.ToUpper(), item.ColumnDescription);
db.DbMaintenance.AddColumnRemark(item.DbColumnName.ToUpper(IsUppper), item.DbTableName.ToUpper(IsUppper), item.ColumnDescription);
}
}
}
@ -462,7 +462,7 @@ namespace SqlSugar
this.Context.Ado.IsEnableLogEvent = false;
string sql = @" select distinct cu.COLUMN_name KEYNAME from user_cons_columns cu, user_constraints au
where cu.constraint_name = au.constraint_name
and au.constraint_type = 'P' and au.table_name = '" + tableName.ToUpper() + @"'";
and au.constraint_type = 'P' and au.table_name = '" + tableName.ToUpper(IsUppper) + @"'";
var pks = this.Context.Ado.SqlQuery<string>(sql);
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
return pks;
@ -478,7 +478,7 @@ namespace SqlSugar
string sql = "SELECT COMMENTS FROM USER_TAB_COMMENTS WHERE TABLE_NAME =@tableName ORDER BY TABLE_NAME";
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
this.Context.Ado.IsEnableLogEvent = false;
var pks = this.Context.Ado.SqlQuery<string>(sql, new { tableName = tableName.ToUpper() });
var pks = this.Context.Ado.SqlQuery<string>(sql, new { tableName = tableName.ToUpper(IsUppper) });
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
return pks;
});
@ -494,7 +494,7 @@ namespace SqlSugar
string sql = "SELECT TABLE_NAME AS TableName, COLUMN_NAME AS DbColumnName,COMMENTS AS ColumnDescription FROM user_col_comments WHERE TABLE_NAME =@tableName ORDER BY TABLE_NAME";
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
this.Context.Ado.IsEnableLogEvent = false;
var pks = this.Context.Ado.SqlQuery<DbColumnInfo>(sql, new { tableName = tableName.ToUpper() });
var pks = this.Context.Ado.SqlQuery<DbColumnInfo>(sql, new { tableName = tableName.ToUpper(IsUppper) });
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
return pks;
});
@ -538,5 +538,22 @@ namespace SqlSugar
return true;
}
#endregion
#region Helper
public bool IsUppper
{
get
{
if (this.Context.CurrentConnectionConfig.MoreSettings == null)
{
return true;
}
else
{
return this.Context.CurrentConnectionConfig.MoreSettings.IsAutoToUpper == true;
}
}
}
#endregion
}
}

22
Src/Asp.NetCore2/SqlSugar/Realization/Oracle/SqlBuilder/OracleBuilder.cs

@ -38,17 +38,17 @@ namespace SqlSugar
if (result.Contains("(") && result.Contains(")"))
return result;
else
return result.ToUpper();
return result.ToUpper(IsUppper);
}
public override string GetTranslationColumnName(string entityName, string propertyName)
{
var result = base.GetTranslationColumnName(entityName, propertyName);
return result.ToUpper();
return result.ToUpper(IsUppper);
}
public override string GetTranslationColumnName(string propertyName)
{
var result = base.GetTranslationColumnName(propertyName);
return result.ToUpper();
return result.ToUpper(IsUppper);
}
public override string RemoveParentheses(string sql)
{
@ -59,5 +59,21 @@ namespace SqlSugar
return sql;
}
#region Helper
public bool IsUppper
{
get
{
if (this.Context.CurrentConnectionConfig.MoreSettings == null)
{
return true;
}
else
{
return this.Context.CurrentConnectionConfig.MoreSettings.IsAutoToUpper == true;
}
}
}
#endregion
}
}

20
Src/Asp.NetCore2/SqlSugar/Realization/Oracle/SqlBuilder/OracleExpressionContext.cs

@ -28,7 +28,7 @@ namespace SqlSugar
public override string SqlTranslationRight { get { return "\""; } }
public override string GetTranslationTableName(string entityName, bool isMapping = true)
{
return base.GetTranslationTableName(entityName, isMapping).ToUpper();
return base.GetTranslationTableName(entityName, isMapping).ToUpper(IsUppper);
}
public override string GetTranslationColumnName(string columnName)
{
@ -39,11 +39,11 @@ namespace SqlSugar
return columnName;
}
else
return base.GetTranslationColumnName(columnName).ToUpper();
return base.GetTranslationColumnName(columnName).ToUpper(IsUppper);
}
public override string GetDbColumnName(string entityName, string propertyName)
{
return base.GetDbColumnName(entityName,propertyName).ToUpper();
return base.GetDbColumnName(entityName,propertyName).ToUpper(IsUppper);
}
public override bool IsTranslationText(string name)
{
@ -54,6 +54,20 @@ namespace SqlSugar
var result = name.IsContainsIn(SqlTranslationLeft, SqlTranslationRight, UtilConstants.Space, ExpressionConst.LeftParenthesis, ExpressionConst.RightParenthesis);
return result;
}
public bool IsUppper
{
get
{
if (this.SugarContext?.Context?.Context?.CurrentConnectionConfig?.MoreSettings == null)
{
return true;
}
else
{
return this.SugarContext?.Context?.Context?.CurrentConnectionConfig?.MoreSettings.IsAutoToUpper == true;
}
}
}
}
public partial class OracleMethod : DefaultDbMethod, IDbMethods
{

19
Src/Asp.NetCore2/SqlSugar/Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs

@ -33,7 +33,7 @@ namespace SqlSugar
private string GetOracleUpdateColums(DbColumnInfo m)
{
return string.Format("\"{0}\"={1}", m.DbColumnName.ToUpper(), FormatValue(m.Value,m.IsPrimarykey,m.PropertyName));
return string.Format("\"{0}\"={1}", m.DbColumnName.ToUpper(IsUppper), FormatValue(m.Value,m.IsPrimarykey,m.PropertyName));
}
int i = 0;
public object FormatValue(object value,bool isPrimaryKey,string name)
@ -112,5 +112,22 @@ namespace SqlSugar
}
}
}
#region Helper
public bool IsUppper
{
get
{
if (this.Context.CurrentConnectionConfig.MoreSettings == null)
{
return true;
}
else
{
return this.Context.CurrentConnectionConfig.MoreSettings.IsAutoToUpper == true;
}
}
}
#endregion
}
}

8
Src/Asp.NetCore2/SqlSugar/Realization/PostgreSQL/PostgreSQLProvider.cs

@ -14,10 +14,10 @@ namespace SqlSugar
{
public PostgreSQLProvider()
{
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
}
public override IDbConnection Connection
{

6
Src/Asp.NetCore2/SqlSugar/Utilities/DbExtensions.cs

@ -96,5 +96,11 @@ namespace SqlSugar
if (isAutoToLower == false) return value;
return value.ToLower();
}
internal static string ToUpper(this string value, bool isAutoToUpper)
{
if (value == null) return null;
if (isAutoToUpper == false) return value;
return value.ToUpper();
}
}
}

3
Src/Asp.NetCore2/SqlSugar/Utilities/UtilMethods.cs

@ -179,7 +179,8 @@ namespace SqlSugar
DisableMillisecond = it.MoreSettings.DisableMillisecond,
DbMinDate=it.MoreSettings.DbMinDate,
IsNoReadXmlDescription=it.MoreSettings.IsNoReadXmlDescription,
SqlServerCodeFirstNvarchar=it.MoreSettings.SqlServerCodeFirstNvarchar
SqlServerCodeFirstNvarchar=it.MoreSettings.SqlServerCodeFirstNvarchar,
IsAutoToUpper=it.MoreSettings.IsAutoToUpper
},
SqlMiddle = it.SqlMiddle == null ? null : new SqlMiddle

Loading…
Cancel
Save