aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-01-12 18:46:17 +0100
committerKim Alvefur <zash@zash.se>2021-01-12 18:46:17 +0100
commit3c919b0ad4b2d2aad3ff5a32487f0c131d70b1b8 (patch)
treecce3ccb858fdb8268b35549efa3ecd66544c9562
parent344d8e7d51106de946ffbfa3f5a8bfc9aa2082af (diff)
downloadprosody-3c919b0ad4b2d2aad3ff5a32487f0c131d70b1b8.tar.gz
prosody-3c919b0ad4b2d2aad3ff5a32487f0c131d70b1b8.zip
mod_storage_sql: Support query for set of IDs
Not compatible with Lua 5.1
-rw-r--r--plugins/mod_storage_sql.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index 9300ed78..9a7d2882 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -283,6 +283,7 @@ archive_store.caps = {
quota = archive_item_limit;
truncate = true;
full_id_range = true;
+ ids = true;
};
archive_store.__index = archive_store
function archive_store:append(username, key, value, when, with)
@@ -376,6 +377,15 @@ local function archive_where(query, args, where)
where[#where+1] = "\"key\" = ?";
args[#args+1] = query.key
end
+
+ -- Set of ids
+ if query.ids then
+ local nids, nargs = #query.ids, #args;
+ where[#where + 1] = "\"key\" IN (" .. string.rep("?", nids, ",") .. ")";
+ for i, id in ipairs(query.ids) do
+ args[nargs+i] = id;
+ end
+ end
end
local function archive_where_id_range(query, args, where)
-- Before or after specific item, exclusive