aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-11-29 08:20:42 +0100
committerKim Alvefur <zash@zash.se>2016-11-29 08:20:42 +0100
commit011ee227bbe13347cb4e97d8ac2a65444ba4d57f (patch)
treefcd54e0e26a738643cba039c055b240a12ce8cb2 /plugins/mod_storage_sql.lua
parentb89b681cd2e5a96767d6503b55dba8df451b8073 (diff)
downloadprosody-011ee227bbe13347cb4e97d8ac2a65444ba4d57f.tar.gz
prosody-011ee227bbe13347cb4e97d8ac2a65444ba4d57f.zip
mod_storage_sql: Create a new table to hold normalized database parameters (fixes #636)
Diffstat (limited to 'plugins/mod_storage_sql.lua')
-rw-r--r--plugins/mod_storage_sql.lua22
1 files changed, 15 insertions, 7 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index b7ade340..fa241ed9 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -433,14 +433,22 @@ local function upgrade_table(params, apply_changes)
return changes;
end
-local function normalize_params(params)
- if params.driver == "SQLite3" then
- if params.database ~= ":memory:" then
- params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite");
- end
+local function normalize_database(driver, database)
+ if driver == "SQLite3" and database ~= ":memory:" then
+ return resolve_relative_path(prosody.paths.data or ".", 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;
+ return database;
+end
+
+local function normalize_params(params)
+ return {
+ driver = assert(params.driver, "Configuration error: Both the SQL driver and the database need to be specified");
+ database = assert(normalize_database(params.driver, params.database), "Configuration error: Both the SQL driver and the database need to be specified");
+ username = params.username;
+ password = params.password;
+ host = params.host;
+ params.port;
+ };
end
function module.load()