fix: sqlite limited delete query bug (#2111)

This commit is contained in:
Abhimanyu 2023-10-09 13:06:40 +02:00 committed by GitHub
parent 83b538e7e2
commit 7bb29b45be

View File

@ -181,9 +181,9 @@ proc deleteMessagesOlderThanTimestamp*(db: SqliteDatabase, ts: int64):
## Delete oldest messages not within limit ## Delete oldest messages not within limit
proc deleteOldestMessagesNotWithinLimitQuery(table: string, limit: int): SqlQueryStr = proc deleteOldestMessagesNotWithinLimitQuery(table: string, limit: int): SqlQueryStr =
"DELETE FROM " & table & " WHERE id NOT IN (" & "DELETE FROM " & table & " WHERE (storedAt, id, pubsubTopic) NOT IN (" &
" SELECT id FROM " & table & " SELECT storedAt, id, pubsubTopic FROM " & table &
" ORDER BY storedAt DESC" & " ORDER BY storedAt DESC, id DESC" &
" LIMIT " & $limit & " LIMIT " & $limit &
");" ");"