aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2010-12-27 06:10:35 +0500
committerWaqas Hussain <waqas20@gmail.com>2010-12-27 06:10:35 +0500
commit86644ab8ab6e47d6ce3edaa18b6f8284d83c9816 (patch)
treee5bcd28143e3151a5dfb281caf1d8c8ac1359bce /plugins
parent799a64f220c19a95ee35e31fb4ebdd5f82fc4c53 (diff)
downloadprosody-86644ab8ab6e47d6ce3edaa18b6f8284d83c9816.tar.gz
prosody-86644ab8ab6e47d6ce3edaa18b6f8284d83c9816.zip
mod_storage_sql: Dynamically replace backquotes with double quotes when connecting to PostgreSQL...
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_storage_sql.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index 12c8eebe..ca024329 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -29,12 +29,13 @@ local json = { stringify = function(s) return require"util.serialization".serial
local connection = ...;
local host,user,store = module.host;
+local params = module:get_option("sql");
do -- process options to get a db connection
local DBI = require "DBI";
- local params = module:get_option("sql") or { driver = "SQLite3", database = "prosody.sqlite" };
- assert(params and params.driver and params.database, "invalid params");
+ params = params or { driver = "SQLite3", database = "prosody.sqlite" };
+ assert(params.driver and params.database, "invalid params");
prosody.unlock_globals();
local dbh, err = DBI.Connect(
@@ -85,6 +86,9 @@ local function deserialize(t, value)
end
local function getsql(sql, ...)
+ if params.driver == "PostgreSQL" then
+ sql = sql:gsub("`", "\"");
+ end
-- do prepared statement stuff
local stmt, err = connection:prepare(sql);
if not stmt then return nil, err; end