Skip to content

Commit 3c97663

Browse files
committed
Fix SQL syntax error of MySQL deleting data. #1673
1 parent bfc0bb3 commit 3c97663

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/DotNetCore.CAP.MySql/IDataStorage.MySql.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ public async Task<int> DeleteExpiresAsync(string table, DateTime timeout, int ba
211211
await using var _ = connection.ConfigureAwait(false);
212212

213213
return await connection.ExecuteNonQueryAsync(
214-
$@"DELETE FROM `{table}`
215-
WHERE Id IN (
214+
$@"DELETE P FROM `{table}` AS P
215+
JOIN (
216216
SELECT Id
217217
FROM `{table}`
218218
WHERE ExpiresAt < @timeout
219219
AND StatusName IN ('{StatusName.Succeeded}', '{StatusName.Failed}')
220220
LIMIT @batchCount
221-
);",
221+
) AS T ON P.Id = T.Id;",
222222
null,
223223
new MySqlParameter("@timeout", timeout),
224224
new MySqlParameter("@batchCount", batchCount)).ConfigureAwait(false);

0 commit comments

Comments
 (0)