From ce07edc7df3be38f3cde1a5f203e1ac9c7217a65 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 27 Jun 2015 15:59:37 +0200 Subject: mod_storage_sql2: Validate configuration after normalizing SQLite3 database path (fixes traceback with default config) --- plugins/mod_storage_sql2.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua index 7c797447..10a16743 100644 --- a/plugins/mod_storage_sql2.lua +++ b/plugins/mod_storage_sql2.lua @@ -379,10 +379,10 @@ local function upgrade_table(params, apply_changes) end local function normalize_params(params) - assert(params.driver and params.database, "Configuration error: Both the SQL driver and the database need to be specified"); if params.driver == "SQLite3" then params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite"); end + assert(params.driver and params.database, "Configuration error: Both the SQL driver and the database need to be specified"); return params; end -- cgit v1.2.3 From 723c6ffe7e5ceb9e9236d9c54d0d4eba1162370d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 27 Jun 2015 16:45:31 +0200 Subject: Remove sql.lib.lua, not used anymore --- plugins/sql.lib.lua | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 plugins/sql.lib.lua diff --git a/plugins/sql.lib.lua b/plugins/sql.lib.lua deleted file mode 100644 index 005ee45d..00000000 --- a/plugins/sql.lib.lua +++ /dev/null @@ -1,9 +0,0 @@ -local cache = module:shared("/*/sql.lib/util.sql"); - -if not cache._M then - prosody.unlock_globals(); - cache._M = require "util.sql"; - prosody.lock_globals(); -end - -return cache._M; -- cgit v1.2.3 From 3dd49f5620ef6860767fee2904399a77e242e10e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 2 Jul 2015 22:32:44 +0200 Subject: util.sql: Call onconnect, provide noop dummy if not set --- util/sql.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/sql.lua b/util/sql.lua index 5aa12f94..92032f43 100644 --- a/util/sql.lua +++ b/util/sql.lua @@ -111,8 +111,12 @@ function engine:connect() self.conn = dbh; self.prepared = {}; self:set_encoding(); + self:onconnect(); return true; end +function engine:onconnect() + -- Override from create_engine() +end function engine:execute(sql, ...) local success, err = self:connect(); if not success then return success, err; end -- cgit v1.2.3