mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 09:24:31 +02:00
parent
b5d0080cd1
commit
bfd74a35bb
2 changed files with 52 additions and 0 deletions
|
|
@ -3554,6 +3554,11 @@ class Table(Queryable):
|
|||
if hash_id_columns and hash_id is None:
|
||||
hash_id = "id"
|
||||
|
||||
if upsert and not pk and not hash_id and self.exists():
|
||||
existing_pks = [column.name for column in self.columns if column.is_pk]
|
||||
if existing_pks:
|
||||
pk = existing_pks[0] if len(existing_pks) == 1 else tuple(existing_pks)
|
||||
|
||||
if upsert and (not pk and not hash_id):
|
||||
raise PrimaryKeyRequired("upsert() requires a pk")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue