# HG changeset patch # User Kim Alvefur # Date 1557751661 -7200 # Node ID 2408e6362c1586db28d792fcee88bec2be78952d # Parent c8646f65767aef4f64b22ec2374b73c59c49b172 mod_storage_sql: Move code out of if-else chain diff -r c8646f65767a -r 2408e6362c15 plugins/mod_storage_sql.lua --- a/plugins/mod_storage_sql.lua Sat May 04 22:48:59 2019 +0200 +++ b/plugins/mod_storage_sql.lua Mon May 13 14:47:41 2019 +0200 @@ -390,6 +390,14 @@ 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 @@ 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);