mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
Update oracle max length
This commit is contained in:
@@ -631,7 +631,14 @@ namespace SqlSugar
|
||||
{
|
||||
var sqlObj = item.ToSql();
|
||||
string sql = sqlObj.Key;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObj.Value.ToArray(), i, "UnionAll");
|
||||
if (this.CurrentConnectionConfig?.MoreSettings?.MaxParameterNameLength > 0)
|
||||
{
|
||||
UtilMethods.RepairReplicationParameters(this.Context,ref sql, sqlObj.Value.ToArray(), i, "UnionAll");
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObj.Value.ToArray(), i, "UnionAll");
|
||||
}
|
||||
if (sqlObj.Value.HasValue())
|
||||
allItems.Add(new KeyValuePair<string, List<SugarParameter>>(sqlBuilder.GetUnionFomatSql(sql), sqlObj.Value));
|
||||
else
|
||||
@@ -668,7 +675,14 @@ namespace SqlSugar
|
||||
item.QueryBuilder.DisableTop = true;
|
||||
var sqlObj = item.ToSql();
|
||||
string sql = sqlObj.Key;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObj.Value.ToArray(), i, "Union");
|
||||
if (this.CurrentConnectionConfig?.MoreSettings?.MaxParameterNameLength > 0)
|
||||
{
|
||||
UtilMethods.RepairReplicationParameters(this.Context, ref sql, sqlObj.Value.ToArray(), i, "Union");
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObj.Value.ToArray(), i, "Union");
|
||||
}
|
||||
if (sqlObj.Value.HasValue())
|
||||
allItems.Add(new KeyValuePair<string, List<SugarParameter>>(sqlBuilder.GetUnionFomatSql(sql), sqlObj.Value));
|
||||
else
|
||||
|
@@ -11,6 +11,31 @@ namespace SqlSugar
|
||||
{
|
||||
public static class CommonExtensions
|
||||
{
|
||||
public static string SafeSubstring(this string str, int startIndex, int length)
|
||||
{
|
||||
if (str == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(str));
|
||||
}
|
||||
|
||||
if (startIndex < 0)
|
||||
{
|
||||
startIndex = 0;
|
||||
}
|
||||
|
||||
if (startIndex >= str.Length)
|
||||
{
|
||||
return string.Empty; // 返回空字符串,因为起始索引超过字符串长度
|
||||
}
|
||||
|
||||
if (length < 0)
|
||||
{
|
||||
length = 0;
|
||||
}
|
||||
|
||||
// 截取字符串时,确保不超过字符串的长度
|
||||
return str.Substring(startIndex, Math.Min(length, str.Length - startIndex));
|
||||
}
|
||||
public static Dictionary<string, object> ToDictionary<T>(this List<T> list, string keyPropertyName, string valuePropertyName)
|
||||
{
|
||||
var keyProperty = typeof(T).GetProperty(keyPropertyName);
|
||||
|
@@ -809,6 +809,25 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
internal static void RepairReplicationParameters(ISqlSugarClient db,ref string appendSql, SugarParameter[] parameters, int addIndex, string append = null)
|
||||
{
|
||||
if (appendSql.HasValue() && parameters.HasValue())
|
||||
{
|
||||
foreach (var parameter in parameters.OrderByDescending(it => it.ParameterName.Length))
|
||||
{
|
||||
//Compatible with.NET CORE parameters case
|
||||
var name = parameter.ParameterName;
|
||||
string newName = name + append + addIndex;
|
||||
var maxLength = db.CurrentConnectionConfig.MoreSettings.MaxParameterNameLength;
|
||||
if (newName.Length > maxLength)
|
||||
{
|
||||
newName = name.SafeSubstring(0,20) + "_" + addIndex;
|
||||
}
|
||||
appendSql = ReplaceSqlParameter(appendSql, parameter, newName);
|
||||
parameter.ParameterName = newName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetPackTable(string sql, string shortName)
|
||||
{
|
||||
|
Reference in New Issue
Block a user