mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update oracle
This commit is contained in:
parent
55d84bbbbe
commit
2efbf34166
@ -232,7 +232,7 @@ namespace SqlSugar
|
||||
string sql = string.Format(this.AddPrimaryKeySql, tableName, string.Format("PK_{0}_{1}", this.SqlBuilder.GetNoTranslationColumnName(tableName), this.SqlBuilder.GetNoTranslationColumnName(columnName)), columnName);
|
||||
if ((tableName+columnName).Length>25 &&this.Context?.CurrentConnectionConfig?.MoreSettings?.MaxParameterNameLength > 0)
|
||||
{
|
||||
sql = string.Format(this.AddPrimaryKeySql, tableName, string.Format("PK_{0}_{1}", this.SqlBuilder.GetNoTranslationColumnName(tableName).SafeSubstring(0,20), "Id"), columnName);
|
||||
sql = string.Format(this.AddPrimaryKeySql, tableName, string.Format("PK_{0}_{1}", this.SqlBuilder.GetNoTranslationColumnName(tableName).GetNonNegativeHashCodeString(), "Id"), columnName);
|
||||
}
|
||||
this.Context.Ado.ExecuteCommand(sql);
|
||||
return true;
|
||||
|
@ -11,6 +11,13 @@ namespace SqlSugar
|
||||
{
|
||||
public static class CommonExtensions
|
||||
{
|
||||
|
||||
public static string GetNonNegativeHashCodeString(this string input)
|
||||
{
|
||||
// 获取哈希码,然后取绝对值,转换为字符串
|
||||
string hashCode = "hs"+Math.Abs(input.GetHashCode());
|
||||
return hashCode;
|
||||
}
|
||||
public static string SafeSubstring(this string str, int startIndex, int length)
|
||||
{
|
||||
if (str == null)
|
||||
|
@ -821,7 +821,7 @@ namespace SqlSugar
|
||||
var maxLength = db.CurrentConnectionConfig.MoreSettings.MaxParameterNameLength;
|
||||
if (newName.Length > maxLength)
|
||||
{
|
||||
newName = name.SafeSubstring(0,20) + "_" + addIndex;
|
||||
newName = name.GetNonNegativeHashCodeString() + "_" + addIndex;
|
||||
}
|
||||
appendSql = ReplaceSqlParameter(appendSql, parameter, newName);
|
||||
parameter.ParameterName = newName;
|
||||
|
Loading…
Reference in New Issue
Block a user