Mercurial > prosody-hg
comparison plugins/mod_storage_sql.lua @ 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 | 41a962b72a6e |
| children | f415176281fa |
comparison
equal
deleted
inserted
replaced
| 11278:c3907f05bed4 | 11279:f225070e2b8a |
|---|---|
| 281 archive_store.caps = { | 281 archive_store.caps = { |
| 282 total = true; | 282 total = true; |
| 283 quota = archive_item_limit; | 283 quota = archive_item_limit; |
| 284 truncate = true; | 284 truncate = true; |
| 285 full_id_range = true; | 285 full_id_range = true; |
| 286 ids = true; | |
| 286 }; | 287 }; |
| 287 archive_store.__index = archive_store | 288 archive_store.__index = archive_store |
| 288 function archive_store:append(username, key, value, when, with) | 289 function archive_store:append(username, key, value, when, with) |
| 289 local user,store = username,self.store; | 290 local user,store = username,self.store; |
| 290 local cache_key = jid_join(username, host, store); | 291 local cache_key = jid_join(username, host, store); |
| 373 | 374 |
| 374 -- Unique id | 375 -- Unique id |
| 375 if query.key then | 376 if query.key then |
| 376 where[#where+1] = "\"key\" = ?"; | 377 where[#where+1] = "\"key\" = ?"; |
| 377 args[#args+1] = query.key | 378 args[#args+1] = query.key |
| 379 end | |
| 380 | |
| 381 -- Set of ids | |
| 382 if query.ids then | |
| 383 local nids, nargs = #query.ids, #args; | |
| 384 where[#where + 1] = "\"key\" IN (" .. string.rep("?", nids, ",") .. ")"; | |
| 385 for i, id in ipairs(query.ids) do | |
| 386 args[nargs+i] = id; | |
| 387 end | |
| 378 end | 388 end |
| 379 end | 389 end |
| 380 local function archive_where_id_range(query, args, where) | 390 local function archive_where_id_range(query, args, where) |
| 381 -- Before or after specific item, exclusive | 391 -- Before or after specific item, exclusive |
| 382 local id_lookup_sql = [[ | 392 local id_lookup_sql = [[ |
