Diff

util/sql.lua @ 8078:60207251863c

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Wed, 12 Apr 2017 20:59:18 +0200
parent 8077:29b3957db212
child 8084:655837e9eeeb
line wrap: on
line diff
--- a/util/sql.lua	Mon Apr 10 23:16:13 2017 +0200
+++ b/util/sql.lua	Wed Apr 12 20:59:18 2017 +0200
@@ -139,6 +139,7 @@
 	if not success then return success, err; end
 	local prepared = self.prepared;
 
+	sql = self:prepquery(sql);
 	local stmt = prepared[sql];
 	if not stmt then
 		local err;
@@ -159,6 +160,7 @@
 
 local function debugquery(where, sql, ...)
 	local i = 0; local a = {...}
+	sql = sql:gsub("\n?\t+", " ");
 	log("debug", "[%s] %s", where, sql:gsub("%?", function () i = i + 1; local v = a[i]; if type(v) == "string" then v = ("%q"):format(v); end return tostring(v); end));
 end
 
@@ -254,7 +256,6 @@
 	if index.unique then
 		sql = sql:gsub("^CREATE", "CREATE UNIQUE");
 	end
-	sql = self:prepquery(sql);
 	if self._debug then
 		debugquery("create", sql);
 	end
@@ -286,7 +287,6 @@
 	if self.params.driver == "MySQL" then
 		sql = sql:gsub(";$", (" CHARACTER SET '%s' COLLATE '%s_bin';"):format(self.charset, self.charset));
 	end
-	sql = self:prepquery(sql);
 	if self._debug then
 		debugquery("create", sql);
 	end