fix: escape %% in SQL

This commit is contained in:
ymq 2026-08-12 12:07:17 +08:00
parent 262280a9ed
commit 99cb2ad8f8

View File

@ -3,12 +3,11 @@
dbname = get_module_dbname('rbac')
async with DBPools().sqlorContext(dbname) as sor:
recs = await sor.sqlExe(
"SELECT path, roleid FROM rolepermission WHERE path LIKE '%login%'", {})
"SELECT path, roleid FROM rolepermission WHERE path LIKE '%%login%%'", {})
perms = [{"path": getattr(r, "path", ""), "roleid": getattr(r, "roleid", "")} for r in (recs or [])]
# Also check up_login
recs2 = await sor.sqlExe(
"SELECT path, roleid FROM rolepermission WHERE path LIKE '%up_login%' OR path LIKE '%login.ui%'", {})
"SELECT path, roleid FROM rolepermission WHERE path LIKE '%%up_login%%' OR path LIKE '%%login.ui%%'", {})
perms2 = [{"path": getattr(r, "path", ""), "roleid": getattr(r, "roleid", "")} for r in (recs2 or [])]
return json.dumps({"login_perms": perms, "up_login_perms": perms2}, ensure_ascii=False)