Skip to content

Commit 801ba14

Browse files
committed
- 修复 UpdateJoin IsVersion 字段的别名问题;
1 parent 5782d6e commit 801ba14

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

FreeSql/Internal/CommonProvider/UpdateProvider.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,24 @@ public virtual void ToSqlExtension110(StringBuilder sb, bool isAsTableSplited)
12161216
if (_versionColumn != null && _versionColumn.Attribute.CanUpdate)
12171217
{
12181218
var vcname = _commonUtils.QuoteSqlName(_versionColumn.Attribute.Name);
1219+
var vcvalue = vcname;
1220+
if (string.IsNullOrWhiteSpace(_tableAlias) == false)
1221+
{
1222+
switch (_orm.Ado.DataType)
1223+
{
1224+
case DataType.PostgreSQL:
1225+
case DataType.OdbcPostgreSQL:
1226+
case DataType.CustomPostgreSQL:
1227+
case DataType.KingbaseES:
1228+
case DataType.OdbcKingbaseES:
1229+
case DataType.ShenTong:
1230+
vcvalue = $"{_tableAlias}.{vcname}"; //set name = b.name
1231+
break;
1232+
default:
1233+
vcname = vcvalue = $"{_tableAlias}.{vcname}"; //set a.name = b.name
1234+
break;
1235+
}
1236+
}
12191237
if (_versionColumn.Attribute.MapType == typeof(byte[]))
12201238
{
12211239
_updateVersionValue = Utils.GuidToBytes(Guid.NewGuid());
@@ -1227,7 +1245,7 @@ public virtual void ToSqlExtension110(StringBuilder sb, bool isAsTableSplited)
12271245
sb.Append(", ").Append(vcname).Append(" = ").Append(_commonUtils.GetNoneParamaterSqlValue(_paramsSource, "uv", _versionColumn, _versionColumn.Attribute.MapType, _updateVersionValue));
12281246
}
12291247
else
1230-
sb.Append(", ").Append(vcname).Append(" = ").Append(_commonUtils.IsNull(vcname, 0)).Append(" + 1");
1248+
sb.Append(", ").Append(vcname).Append(" = ").Append(_commonUtils.IsNull(vcvalue, 0)).Append(" + 1");
12311249
}
12321250
ToSqlWhere(sb);
12331251
_interceptSql?.Invoke(sb);

0 commit comments

Comments
 (0)