Skip to content

Commit d5fbf54

Browse files
authored
pg: fix has_privileges function to quote schema and table names (#7574)
1 parent 772b160 commit d5fbf54

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

redash/query_runner/pg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def _get_tables(self, schema):
223223
AND a.attnum > 0
224224
AND NOT a.attisdropped
225225
WHERE c.relkind = 'm'
226-
AND has_table_privilege(s.nspname || '.' || c.relname, 'select')
226+
AND has_table_privilege(quote_ident(s.nspname) || '.' || quote_ident(c.relname), 'select')
227227
AND has_schema_privilege(s.nspname, 'usage')
228228
229229
UNION
@@ -234,7 +234,7 @@ def _get_tables(self, schema):
234234
data_type
235235
FROM information_schema.columns
236236
WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
237-
AND has_table_privilege(table_schema || '.' || table_name, 'select')
237+
AND has_table_privilege(quote_ident(table_schema) || '.' || quote_ident(table_name), 'select')
238238
AND has_schema_privilege(table_schema, 'usage')
239239
"""
240240

0 commit comments

Comments
 (0)