# HG changeset patch # User Waqas Hussain # Date 1293412235 -18000 # Node ID 61ae809da8ee27ad2f21d316ceabd1587c365889 # Parent d3f5c60a72b1267a06f9708b85f84d70335c77fb mod_storage_sql: Dynamically replace backquotes with double quotes when connecting to PostgreSQL... diff -r d3f5c60a72b1 -r 61ae809da8ee plugins/mod_storage_sql.lua --- a/plugins/mod_storage_sql.lua Mon Dec 27 06:10:35 2010 +0500 +++ b/plugins/mod_storage_sql.lua Mon Dec 27 06:10:35 2010 +0500 @@ -29,12 +29,13 @@ 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 @@ 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