修复DB2字段类型语法转换问题

This commit is contained in:
Kenton 2025-05-28 17:12:01 +08:00
parent 501deb47cf
commit 9cff765f8b
4 changed files with 33 additions and 24 deletions

File diff suppressed because one or more lines are too long

View File

@ -30,7 +30,7 @@ public class DbHelper
/// Database connection string
/// 数据库连接字符串
/// </summary>
public readonly static string Connection = "server=127.0.0.1:50000;database=Test;uid=db2inst1;pwd=123456;currentSchema=db2inst1;";
public readonly static string Connection = "server=127.0.0.1:50000;database=Test;uid=db2inst1;pwd=123456;currentSchema=db2inst1;";
/// <summary>
/// Get a new SqlSugarClient instance with specific configurations

View File

@ -342,7 +342,8 @@ namespace SqlSugar.DB2
public override string ToString(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
return string.Format(" CAST({0} AS VARCHAR)", parameter.MemberName);
var valueLength = parameter.MemberValue.IsNullOrEmpty() ? 1 : parameter.MemberValue?.ToString().Length;
return string.Format($" CAST({{0}} AS VARCHAR({valueLength}))", parameter.MemberName);
}
public override string ToGuid(MethodCallExpressionModel model)

View File

@ -47,25 +47,6 @@ namespace SqlSugar.DB2
}
}
//public override string GetWhereValueString
//{
// get
// {
// return base.GetWhereValueString.Replace("\"", "".ToUpper()); ;
// }
//}
//public override string GetJoinValueString
//{
// get
// {
// if (this.JoinQueryInfos.IsNullOrEmpty()) return null;
// else
// {
// return string.Join(UtilConstants.Space, this.JoinQueryInfos.Select(it => this.ToJoinString(it).Replace("\"", "").ToUpper()));
// }
// }
//}
public override bool IsComplexModel(string sql)
{
@ -153,7 +134,7 @@ namespace SqlSugar.DB2
{
var selectParams = selectSql.Split(",").Select(p =>
{
if (!Regex.IsMatch(p, constRegex)) return p;
if (!Regex.IsMatch(p.ToLower(), constRegex)) return p;
var parameterItems = this.Parameters.Where(t => p.Contains(t.ParameterName)).ToList();
if (!parameterItems.Any()) return p;