Skip to content

Commit b6b4669

Browse files
committed
refactor(postgres): use a bindparam for metadata queries
1 parent 5df1d54 commit b6b4669

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ibis/backends/postgres/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,15 @@ def _metadata(self, query: str) -> Iterable[tuple[str, dt.DataType]]:
181181
attname,
182182
format_type(atttypid, atttypmod) AS type
183183
FROM pg_attribute
184-
WHERE attrelid = {raw_name!r}::regclass
184+
WHERE attrelid = CAST(:raw_name AS regclass)
185185
AND attnum > 0
186186
AND NOT attisdropped
187-
ORDER BY attnum
188-
"""
187+
ORDER BY attnum"""
189188
with self.begin() as con:
190189
con.execute(sa.text(f"CREATE TEMPORARY VIEW {name} AS {query}"))
191-
type_info = con.execute(sa.text(type_info_sql))
190+
type_info = con.execute(
191+
sa.text(type_info_sql).bindparams(raw_name=raw_name)
192+
)
192193
yield from ((col, _get_type(typestr)) for col, typestr in type_info)
193194
con.execute(sa.text(f"DROP VIEW IF EXISTS {name}"))
194195

0 commit comments

Comments
 (0)