aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-04-13 22:37:35 +0200
committerKim Alvefur <zash@zash.se>2017-04-13 22:37:35 +0200
commit656c5d45a1bfd3d53a2e3b675fbd95c870b170aa (patch)
tree434831542f3b56b1e49f2ad4f2155de72250a991
parentcaf3175a5f2b457c97bfe6ba217a2fcc0661baf2 (diff)
downloadprosody-656c5d45a1bfd3d53a2e3b675fbd95c870b170aa.tar.gz
prosody-656c5d45a1bfd3d53a2e3b675fbd95c870b170aa.zip
util.sql: Produce more SQL-standard-like debug messages
-rw-r--r--util/sql.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/util/sql.lua b/util/sql.lua
index f7c68ed3..15749911 100644
--- a/util/sql.lua
+++ b/util/sql.lua
@@ -161,7 +161,14 @@ local result_mt = { __index = {
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));
+ log("debug", "[%s] %s", where, sql:gsub("%?", function ()
+ i = i + 1;
+ local v = a[i];
+ if type(v) == "string" then
+ v = ("'%s'"):format(v:gsub("'", "''"));
+ end
+ return tostring(v);
+ end));
end
function engine:execute_query(sql, ...)