diff --git a/resources/install/scripts/resources/functions/database.lua b/resources/install/scripts/resources/functions/database.lua index a073e7f8b4..91bb5f5390 100644 --- a/resources/install/scripts/resources/functions/database.lua +++ b/resources/install/scripts/resources/functions/database.lua @@ -85,6 +85,14 @@ local function new_database(backend) assert(x == 1, ("Got %d expected %d"):format(x, 1)) end + do local x = 0 + db:query("select 1 as v union all select 2 as v", function(row) + x = x + 1 + return -1 + end) + assert(x == 1, ("Got %d expected %d"):format(x, 1)) + end + do local x = 0 db:query("select 1 as v union all select 2 as v", function(row) x = x + 1 diff --git a/resources/install/scripts/resources/functions/database/luasql.lua b/resources/install/scripts/resources/functions/database/luasql.lua index 00bb965609..010481d0db 100644 --- a/resources/install/scripts/resources/functions/database/luasql.lua +++ b/resources/install/scripts/resources/functions/database/luasql.lua @@ -54,7 +54,7 @@ function LuaSQLDatabase:query(sql, fn) local row, err = cur:fetch({}, "a") if not row then break end local ok, ret = pcall(fn, apply_names(row, colnames, "")) - if (not ok) or (type(ret) == 'number' and ret > 0) then + if (not ok) or (type(ret) == 'number' and ret ~= 0) then break end end