Changeset

11279:f225070e2b8a

mod_storage_sql: Support query for set of IDs Not compatible with Lua 5.1
author Kim Alvefur <zash@zash.se>
date Tue, 12 Jan 2021 18:46:17 +0100
parents 11278:c3907f05bed4
children 11280:e35e98541ca0
files plugins/mod_storage_sql.lua
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua	Tue Jan 12 18:06:55 2021 +0100
+++ b/plugins/mod_storage_sql.lua	Tue Jan 12 18:46:17 2021 +0100
@@ -283,6 +283,7 @@
 	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 @@
 		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