Skip to content

Commit

Permalink
[fix]pgsql 在进行 InsertAndGetIdentity 时,不能固定写死 RETURNING id,因为自增列名称是不固定…
Browse files Browse the repository at this point in the history
…的。正确的做法是将自增列通过参数传递进来,但对代码的调整较大。故参照人大金仓的实现,使用 RETURNING * 。
  • Loading branch information
Soar360 committed Sep 10, 2024
1 parent 1636b3a commit 84de516
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions XCode/DataAccessLayer/Database/PostgreSQL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ public override DbTable Query(SelectBuilder builder)
/// <returns>新增行的自动编号</returns>
public override Int64 InsertAndGetIdentity(String sql, CommandType type = CommandType.Text, params IDataParameter[] ps)

Check warning on line 239 in XCode/DataAccessLayer/Database/PostgreSQL.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of type of parameter 'ps' doesn't match overridden member (possibly because of nullability attributes).
{
sql += " RETURNING id";
sql = sql + $" RETURNING *";
return base.InsertAndGetIdentity(sql, type, ps);
}

public override Task<Int64> InsertAndGetIdentityAsync(String sql, CommandType type = CommandType.Text, params IDataParameter[] ps)
{
sql += " RETURNING id";
sql = sql + $" RETURNING *";
return base.InsertAndGetIdentityAsync(sql, type, ps);
}

Expand Down

0 comments on commit 84de516

Please sign in to comment.