# HG changeset patch # User Kim Alvefur # Date 1690035348 -7200 # Node ID 0d3881bf29a889d3cd7c4111db37ab38f956d2aa # Parent 0419de4e4db1de50ae0d536be7fe4c19dc7289f9 mod_storage_sql: Spell out missing dependencies Using util.dependencies appeared to cause problems with running tests in Busted, so this also removes that and uses pcall directly. diff -r 0419de4e4db1 -r 0d3881bf29a8 plugins/mod_storage_sql.lua --- a/plugins/mod_storage_sql.lua Sat Jul 22 15:22:54 2023 +0200 +++ b/plugins/mod_storage_sql.lua Sat Jul 22 16:15:48 2023 +0200 @@ -1,11 +1,8 @@ -- luacheck: ignore 212/self -local deps = require "prosody.util.dependencies"; local cache = require "prosody.util.cache"; local json = require "prosody.util.json"; -local sqlite = deps.softreq "prosody.util.sqlite3"; -local dbisql = (sqlite and deps.softreq or require) "prosody.util.sql"; local xml_parse = require "prosody.util.xml".parse; local uuid = require "prosody.util.uuid"; local resolve_relative_path = require "prosody.util.paths".resolve_relative_path; @@ -14,6 +11,22 @@ local is_stanza = require"prosody.util.stanza".is_stanza; local t_concat = table.concat; +local have_dbisql, dbisql = pcall(require, "prosody.util.sql"); +local have_sqlite, sqlite = pcall(require, "prosody.util.sqlite3"); +if not have_dbisql then + module:log("debug", "Could not load LuaDBI, error was: %s", dbisql) + dbisql = nil; +end +if not have_sqlite then + module:log("debug", "Could not load LuaSQLite3, error was: %s", sqlite) + sqlite = nil; +end +if not (have_dbisql or have_sqlite) then + module:log("error", "LuaDBI or LuaSQLite3 are required for using SQL databases but neither are installed"); + module:log("error", "Please install at least one of LuaDBI and LuaSQLite3. See https://prosody.im/doc/depends"); + error("No SQL library available") +end + local noop = function() end local unpack = table.unpack; local function iterator(result)