util.sql: Return an error message when a SQL commit fails (LuaDBI doesn't) (Thanks Ge0rG)
authorKim Alvefur <zash@zash.se>
Tue, 07 Nov 2017 09:26:48 +0100
changeset 8381 6a098961bc00
parent 8371 3629639d5fa9
child 8382 2a0915aa6131
child 8391 9ee56e9ad47a
util.sql: Return an error message when a SQL commit fails (LuaDBI doesn't) (Thanks Ge0rG)
util/sql.lua
--- a/util/sql.lua	Fri Nov 03 01:17:39 2017 +0100
+++ b/util/sql.lua	Tue Nov 07 09:26:48 2017 +0100
@@ -236,7 +236,8 @@
 	if success then
 		log("debug", "SQL transaction success [%s]", tostring(func));
 		local ok, err = self.conn:commit();
-		if not ok then return ok, err; end -- commit failed
+		-- LuaDBI doesn't actually return an error message here, just a boolean
+		if not ok then return ok, err or "commit failed"; end
 		return success, a, b, c;
 	else
 		log("debug", "SQL transaction failure [%s]: %s", tostring(func), a.err);