Skip to content

Commit

Permalink
- 修复 SqlServer 批量更新 bool? null 值生成多余的 case when SQL;
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Dec 13, 2023
1 parent 09c8725 commit 2368377
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 113 deletions.
210 changes: 98 additions & 112 deletions FreeSql/FreeSql.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion FreeSql/Internal/CommonProvider/UpdateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ protected string WhereCaseSource(string CsName, Func<string, string> thenValue)
new[] { typeof(string), typeof(DateTime), typeof(DateTime?) }.Contains(col.Attribute.MapType) ||
col.Attribute.MapType.NullableTypeOrThis().IsEnum;
var ds = _source.Select(a => col.GetDbValue(a)).ToArray();
if (valsameIf == false && ds[0] == null) valsameIf = true;
if (valsameIf && ds.All(a => object.Equals(a, ds[0])))
{
var val = ds.First();
Expand Down Expand Up @@ -1119,7 +1120,8 @@ public virtual void ToSqlExtension110(StringBuilder sb, bool isAsTableSplited)
new[] { typeof(string), typeof(DateTime), typeof(DateTime?) }.Contains(col.Attribute.MapType) ||
col.Attribute.MapType.NullableTypeOrThis().IsEnum;
var ds = _source.Select(a => col.GetDbValue(a)).ToArray();
if (valsameIf && ds.All(a => object.Equals(a, ds[0])))
if (valsameIf == false && ds[0] == null) valsameIf = true;
if (valsameIf && ds.All(a => object.Equals(a, ds[0])))
{
var val = ds.First();
var colsql = _noneParameter ? _commonUtils.GetNoneParamaterSqlValue(_paramsSource, "u", col, col.Attribute.MapType, val) :
Expand Down

0 comments on commit 2368377

Please sign in to comment.