summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2014-11-28 15:23:33 +0000
committerTed Trask <ttrask01@yahoo.com>2014-11-28 15:23:33 +0000
commit3ae5b45b187738b67146230666fc4d2f9fd5458d (patch)
treebe7d1eb624c2d38b1b3bf5b3db6fb7557e30612b
parent55361d60346849a4bef6cb98af1b41f6b6b50af6 (diff)
downloadacf-lib-3ae5b45b187738b67146230666fc4d2f9fd5458d.tar.bz2
acf-lib-3ae5b45b187738b67146230666fc4d2f9fd5458d.tar.xz
Fix db bug when execute(sql) returns a number instead of a cursor
-rw-r--r--db.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/db.lua b/db.lua
index 626b268..0b6da43 100644
--- a/db.lua
+++ b/db.lua
@@ -96,7 +96,10 @@ export.getselectresponse = function(dbobject, sql, transaction)
if transaction then assert(dbobject.con:execute("SAVEPOINT before_select")) end
local res, err = pcall(function()
local cur = assert (dbobject.con:execute(sql))
- local row = cur:fetch ({}, "a")
+ local row
+ if type(cur) == "userdata" then
+ row = cur:fetch ({}, "a")
+ end
while row do
local tmp = {}
for name,val in pairs(row) do
@@ -105,7 +108,9 @@ export.getselectresponse = function(dbobject, sql, transaction)
retval[#retval + 1] = tmp
row = cur:fetch (row, "a")
end
- cur:close()
+ if type(cur) == "userdata" then
+ cur:close()
+ end
end)
if not res and err then
-- Catch the error to see if it's caused by lack of table