mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
Update oracle
This commit is contained in:
@@ -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);
|
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)
|
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);
|
this.Context.Ado.ExecuteCommand(sql);
|
||||||
return true;
|
return true;
|
||||||
|
@@ -11,6 +11,13 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public static class CommonExtensions
|
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)
|
public static string SafeSubstring(this string str, int startIndex, int length)
|
||||||
{
|
{
|
||||||
if (str == null)
|
if (str == null)
|
||||||
|
@@ -821,7 +821,7 @@ namespace SqlSugar
|
|||||||
var maxLength = db.CurrentConnectionConfig.MoreSettings.MaxParameterNameLength;
|
var maxLength = db.CurrentConnectionConfig.MoreSettings.MaxParameterNameLength;
|
||||||
if (newName.Length > maxLength)
|
if (newName.Length > maxLength)
|
||||||
{
|
{
|
||||||
newName = name.SafeSubstring(0,20) + "_" + addIndex;
|
newName = name.GetNonNegativeHashCodeString() + "_" + addIndex;
|
||||||
}
|
}
|
||||||
appendSql = ReplaceSqlParameter(appendSql, parameter, newName);
|
appendSql = ReplaceSqlParameter(appendSql, parameter, newName);
|
||||||
parameter.ParameterName = newName;
|
parameter.ParameterName = newName;
|
||||||
|
Reference in New Issue
Block a user