Skip to content

Commit

Permalink
- 修复 IUpdate.SetSource SqlServer 批量更新 Cast 问题;#1755
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Mar 22, 2024
1 parent ce8d699 commit 63a8e8e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected override void ToSqlCase(StringBuilder caseWhen, ColumnInfo[] primarys)
foreach (var pk in primarys)
{
if (pkidx > 0) caseWhen.Append(" + '+' + ");
caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar)");
caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar(2000))");
++pkidx;
}
caseWhen.Append(")");
Expand All @@ -107,7 +107,7 @@ protected override void ToSqlWhen(StringBuilder sb, ColumnInfo[] primarys, objec
foreach (var pk in primarys)
{
if (pkidx > 0) sb.Append(" + '+' + ");
sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar)");
sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar(2000))");
++pkidx;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected override void ToSqlCase(StringBuilder caseWhen, ColumnInfo[] primarys)
foreach (var pk in primarys)
{
if (pkidx > 0) caseWhen.Append(" + '+' + ");
caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar)");
caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar(2000))");
++pkidx;
}
caseWhen.Append(")");
Expand All @@ -107,7 +107,7 @@ protected override void ToSqlWhen(StringBuilder sb, ColumnInfo[] primarys, objec
foreach (var pk in primarys)
{
if (pkidx > 0) sb.Append(" + '+' + ");
sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar)");
sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar(2000))");
++pkidx;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Providers/FreeSql.Provider.SqlServer/Curd/SqlServerUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected override void ToSqlCase(StringBuilder caseWhen, ColumnInfo[] primarys)
foreach (var pk in primarys)
{
if (pkidx > 0) caseWhen.Append(" + '+' + ");
caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar)");
caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar(2000))");
++pkidx;
}
caseWhen.Append(")");
Expand All @@ -107,7 +107,7 @@ protected override void ToSqlWhen(StringBuilder sb, ColumnInfo[] primarys, objec
foreach (var pk in primarys)
{
if (pkidx > 0) sb.Append(" + '+' + ");
sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar)");
sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar(2000))");
++pkidx;
}
}
Expand Down

0 comments on commit 63a8e8e

Please sign in to comment.