Views should be double quoted too

This commit is contained in:
Simon Willison 2025-11-23 20:06:44 -08:00
commit 98dd284f6b
3 changed files with 20 additions and 13 deletions

View file

@ -1177,7 +1177,9 @@ class Database:
assert not (
ignore and replace
), "Use one or the other of ignore/replace, not both"
create_sql = "CREATE VIEW {name} AS {sql}".format(name=name, sql=sql)
create_sql = "CREATE VIEW {name} AS {sql}".format(
name=quote_identifier(name), sql=sql
)
if ignore or replace:
# Does view exist already?
if name in self.view_names():