Fix. LuaSQL db backend breaks loop only on positive numbers.

This commit is contained in:
Alexey Melnichuk
2016-02-26 13:57:05 +03:00
parent b797775720
commit bd4fa2a537
2 changed files with 9 additions and 1 deletions

View File

@@ -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

View File

@@ -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