Skip to content

Commit e81142e

Browse files
goldenbullchenjn
andauthored
fix: pgsql IN operator must work with ANY operator (#906)
Co-authored-by: chenjn <chenjn@vm>
1 parent f8bcb10 commit e81142e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Ui/Service/DataSource/DAO/Dapper/DapperDataBase.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,11 @@ public override Result DeleteServer(IEnumerable<string> ids)
384384
if (!result.IsSuccess) return result;
385385
try
386386
{
387-
var ret = _dbConnection?.Execute(NormalizedSql($@"DELETE FROM `{Server.TABLE_NAME}` WHERE `{nameof(Server.Id)}` IN @{nameof(Server.Id)};"), new { Id = ids }) > 0;
387+
// special case: dapper does not support IN operator for postgresql
388+
var sql = DatabaseType == DatabaseType.PostgreSQL
389+
? $@"DELETE FROM `{Server.TABLE_NAME}` WHERE `{nameof(Server.Id)}` = ANY(@{nameof(Server.Id)});"
390+
: $@"DELETE FROM `{Server.TABLE_NAME}` WHERE `{nameof(Server.Id)}` IN @{nameof(Server.Id)};";
391+
var ret = _dbConnection?.Execute(NormalizedSql(sql), new { Id = ids }) > 0;
388392
if (ret)
389393
SetDataUpdateTimestamp();
390394
return Result.Success();

0 commit comments

Comments
 (0)