util.sql: Apply quote transform in engine:execute so it is applied to eg encoding checks in mod_storage_sql (thanks Martin)
authorKim Alvefur <zash@zash.se>
Wed, 12 Apr 2017 17:26:44 +0200
changeset 8079 6e0defa19ab9
parent 8078 a4dd08fd64cf
child 8080 29b3957db212
util.sql: Apply quote transform in engine:execute so it is applied to eg encoding checks in mod_storage_sql (thanks Martin)
util/sql.lua
--- a/util/sql.lua	Wed Apr 12 17:26:13 2017 +0200
+++ b/util/sql.lua	Wed Apr 12 17:26:44 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;
@@ -254,7 +255,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 +286,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