mirror of
https://github.com/simonw/datasette.git
synced 2026-09-11 11:04:07 +02:00
Escape identifiers in upsert row readback
This commit is contained in:
parent
158c88f259
commit
4c56ce2103
1 changed files with 9 additions and 3 deletions
|
|
@ -1161,13 +1161,19 @@ class TableInsertView(BaseView):
|
|||
if upsert:
|
||||
# Fetch based on initial input IDs
|
||||
where_clause = " OR ".join(
|
||||
["({})".format(" AND ".join(f"{pk} = ?" for pk in pks))]
|
||||
[
|
||||
"({})".format(
|
||||
" AND ".join(f"{escape_sqlite(pk)} = ?" for pk in pks)
|
||||
)
|
||||
]
|
||||
* len(row_pk_values_for_later)
|
||||
)
|
||||
args = list(itertools.chain.from_iterable(row_pk_values_for_later))
|
||||
fetched_rows = await db.execute(
|
||||
"select {}* from [{}] where {}".format(
|
||||
"rowid, " if pks == ["rowid"] else "", table_name, where_clause
|
||||
"select {}* from {} where {}".format(
|
||||
"rowid, " if pks == ["rowid"] else "",
|
||||
escape_sqlite(table_name),
|
||||
where_clause,
|
||||
),
|
||||
args,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue