pg: fix has_privileges function to quote schema and table names (#7574)

This commit is contained in:
Sarvesh Vazarkar
2025-11-20 16:14:03 +01:00
committed by GitHub
parent 772b160a79
commit d5fbf547cf

View File

@@ -223,7 +223,7 @@ class PostgreSQL(BaseSQLQueryRunner):
AND a.attnum > 0
AND NOT a.attisdropped
WHERE c.relkind = 'm'
AND has_table_privilege(s.nspname || '.' || c.relname, 'select')
AND has_table_privilege(quote_ident(s.nspname) || '.' || quote_ident(c.relname), 'select')
AND has_schema_privilege(s.nspname, 'usage')
UNION
@@ -234,7 +234,7 @@ class PostgreSQL(BaseSQLQueryRunner):
data_type
FROM information_schema.columns
WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
AND has_table_privilege(table_schema || '.' || table_name, 'select')
AND has_table_privilege(quote_ident(table_schema) || '.' || quote_ident(table_name), 'select')
AND has_schema_privilege(table_schema, 'usage')
"""