aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-05-28 00:46:24 +0200
committerKim Alvefur <zash@zash.se>2019-05-28 00:46:24 +0200
commit8799bf12c702335a32d1d220269090f653230b0d (patch)
tree77ff08c02a2a43ac136d0eb681981b6e37b96e4b
parent11d7a43acb43ea908d48dc62ab1e2871a08b4834 (diff)
downloadprosody-8799bf12c702335a32d1d220269090f653230b0d.tar.gz
prosody-8799bf12c702335a32d1d220269090f653230b0d.zip
mod_storage_sql: Correctly return item-not-found error
`return ok, err` comes out as `transaction_ok, ok, err`
-rw-r--r--plugins/mod_storage_sql.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index 5da5e448..cfc8450c 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -367,7 +367,7 @@ function archive_store:find(username, query)
if total ~= nil and query.limit == 0 and query.start == nil and query.with == nil and query["end"] == nil and query.key == nil then
return noop, total;
end
- local ok, result = engine:transaction(function()
+ local ok, result, err = engine:transaction(function()
local sql_query = [[
SELECT "key", "type", "value", "when", "with"
FROM "prosodyarchive"
@@ -407,7 +407,8 @@ function archive_store:find(username, query)
and "DESC" or "ASC", query.limit and " LIMIT ?" or "");
return engine:select(sql_query, unpack(args));
end);
- if not ok then return ok, result end
+ if not ok then return ok, result; end
+ if not result then return nil, err; end
return function()
local row = result();
if row ~= nil then