PG临时主键插入或更新时自增主键不插入

This commit is contained in:
yangl
2025-10-29 21:06:16 +08:00
parent 8d796b75e7
commit ffb7d3823b
2 changed files with 27 additions and 1 deletions

View File

@@ -58,7 +58,7 @@ namespace FreeSql.PostgreSQL.Curd
if (IdentityColumn != null && flagInsert) sql = insert.ToSql();
else
{
var ocdu = new OnConflictDoUpdate<T1>(insert.InsertIdentity());
var ocdu = new OnConflictDoUpdate<T1>(_tempPrimarys?.Length > 0 ? insert : insert.InsertIdentity());
ocdu._tempPrimarys = _tempPrimarys;
var cols = _table.Columns.Values.Where(a => _updateSetDict.ContainsKey(a.Attribute.Name) ||
_tempPrimarys.Contains(a) == false && a.Attribute.CanUpdate == true && a.Attribute.IsIdentity == false && _updateIgnore.ContainsKey(a.Attribute.Name) == false);