File

plugins/mod_debug_sql.lua @ 13684:026a75a443de 13.0

mod_admin_shell: Hide secondary role commands, focus on primary roles Secondary roles are an advanced feature without any strong use cases currently. Having multiple ways to manage roles is confusing. Now the 'user:role' command will just show the primary role if that is all there is, but will list secondary roles too if there are any (which in 99.9% of cases there won't be).
author Matthew Wild <mwild1@gmail.com>
date Thu, 13 Feb 2025 16:18:59 +0000
parent 8391:5edb0d01a94f
line wrap: on
line source

-- Enables SQL query logging
--
-- luacheck: ignore 213/uri

module:set_global();

local engines = module:shared("/*/sql/connections");

for uri, engine in pairs(engines) do
	engine:debug(true);
end

setmetatable(engines, {
	__newindex = function (t, uri, engine)
		engine:debug(true);
		rawset(t, uri, engine);
	end
});

function module.unload()
	setmetatable(engines, nil);
	for uri, engine in pairs(engines) do
		engine:debug(false);
	end
end