aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-05-13 14:47:41 +0200
committerKim Alvefur <zash@zash.se>2019-05-13 14:47:41 +0200
commite54ee56ed145cf17cfaad992ef445dec287ed471 (patch)
tree37b8ec274c2f8c0074f5184e8c1f82195b97f4bb /plugins/mod_storage_sql.lua
parente0000f5fa615d0f55195f55bd0e7d20c6b16651b (diff)
downloadprosody-e54ee56ed145cf17cfaad992ef445dec287ed471.tar.gz
prosody-e54ee56ed145cf17cfaad992ef445dec287ed471.zip
mod_storage_sql: Move code out of if-else chain
Diffstat (limited to 'plugins/mod_storage_sql.lua')
-rw-r--r--plugins/mod_storage_sql.lua17
1 files changed, 8 insertions, 9 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index 56cef569..dbf5e2da 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -390,6 +390,14 @@ function archive_store:delete(username, query)
else
args[#args+1] = query.truncate;
local unlimited = "ALL";
+ sql_query = [[
+ DELETE FROM "prosodyarchive"
+ WHERE "sort_id" IN (
+ SELECT "sort_id" FROM "prosodyarchive"
+ WHERE %s
+ ORDER BY "sort_id" %s
+ LIMIT %s OFFSET ?
+ );]];
if engine.params.driver == "SQLite3" then
sql_query = [[
DELETE FROM "prosodyarchive"
@@ -407,15 +415,6 @@ function archive_store:delete(username, query)
LIMIT %s OFFSET ?
) AS limiter on result.sort_id = limiter.sort_id;]];
unlimited = "18446744073709551615";
- else
- sql_query = [[
- DELETE FROM "prosodyarchive"
- WHERE "sort_id" IN (
- SELECT "sort_id" FROM "prosodyarchive"
- WHERE %s
- ORDER BY "sort_id" %s
- LIMIT %s OFFSET ?
- );]];
end
sql_query = string.format(sql_query, t_concat(where, " AND "),
query.reverse and "ASC" or "DESC", unlimited);