Mercurial > prosody-hg
comparison plugins/mod_storage_sql.lua @ 7752:56abe6a8e761
mod_storage_sql: Create a new table to hold normalized database parameters (fixes #636)
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 29 Nov 2016 08:20:42 +0100 |
| parents | 168919a947ed |
| children | c276d72d4e17 |
comparison
equal
deleted
inserted
replaced
| 7751:168919a947ed | 7752:56abe6a8e761 |
|---|---|
| 431 end | 431 end |
| 432 end | 432 end |
| 433 return changes; | 433 return changes; |
| 434 end | 434 end |
| 435 | 435 |
| 436 local function normalize_database(driver, database) | |
| 437 if driver == "SQLite3" and database ~= ":memory:" then | |
| 438 return resolve_relative_path(prosody.paths.data or ".", database or "prosody.sqlite"); | |
| 439 end | |
| 440 return database; | |
| 441 end | |
| 442 | |
| 436 local function normalize_params(params) | 443 local function normalize_params(params) |
| 437 if params.driver == "SQLite3" then | 444 return { |
| 438 if params.database ~= ":memory:" then | 445 driver = assert(params.driver, "Configuration error: Both the SQL driver and the database need to be specified"); |
| 439 params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite"); | 446 database = assert(normalize_database(params.driver, params.database), "Configuration error: Both the SQL driver and the database need to be specified"); |
| 440 end | 447 username = params.username; |
| 441 end | 448 password = params.password; |
| 442 assert(params.driver and params.database, "Configuration error: Both the SQL driver and the database need to be specified"); | 449 host = params.host; |
| 443 return params; | 450 params.port; |
| 451 }; | |
| 444 end | 452 end |
| 445 | 453 |
| 446 function module.load() | 454 function module.load() |
| 447 if prosody.prosodyctl then return; end | 455 if prosody.prosodyctl then return; end |
| 448 local engines = module:shared("/*/sql/connections"); | 456 local engines = module:shared("/*/sql/connections"); |
