mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-13 12:54:12 +02:00
Use quote_identifier() in indexes/xindexes PRAGMA statements (#825)
Closes #824
This commit is contained in:
parent
c5063f67b1
commit
e6be6267a4
2 changed files with 29 additions and 10 deletions
|
|
@ -2375,14 +2375,11 @@ class Table(Queryable):
|
|||
@property
|
||||
def indexes(self) -> list[Index]:
|
||||
"List of indexes defined on this table."
|
||||
sql = f'PRAGMA index_list("{self.name}")'
|
||||
sql = f"PRAGMA index_list({quote_identifier(self.name)})"
|
||||
indexes = []
|
||||
for row in self.db.execute_returning_dicts(sql):
|
||||
index_name = row["name"]
|
||||
index_name_quoted = (
|
||||
f'"{index_name}"' if not index_name.startswith('"') else index_name
|
||||
)
|
||||
column_sql = f"PRAGMA index_info({index_name_quoted})"
|
||||
column_sql = f"PRAGMA index_info({quote_identifier(index_name)})"
|
||||
columns = []
|
||||
for seqno, cid, name in self.db.execute(column_sql).fetchall():
|
||||
columns.append(name)
|
||||
|
|
@ -2397,14 +2394,11 @@ class Table(Queryable):
|
|||
@property
|
||||
def xindexes(self) -> list[XIndex]:
|
||||
"List of indexes defined on this table using the more detailed ``XIndex`` format."
|
||||
sql = f'PRAGMA index_list("{self.name}")'
|
||||
sql = f"PRAGMA index_list({quote_identifier(self.name)})"
|
||||
indexes = []
|
||||
for row in self.db.execute_returning_dicts(sql):
|
||||
index_name = row["name"]
|
||||
index_name_quoted = (
|
||||
f'"{index_name}"' if not index_name.startswith('"') else index_name
|
||||
)
|
||||
column_sql = f"PRAGMA index_xinfo({index_name_quoted})"
|
||||
column_sql = f"PRAGMA index_xinfo({quote_identifier(index_name)})"
|
||||
index_columns = []
|
||||
for info in self.db.execute(column_sql).fetchall():
|
||||
index_columns.append(XIndexColumn(*info))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue