Skip to content

Commit 2ab894d

Browse files
committed
Remove upsert() requires a pk checks
1 parent fe3a3d4 commit 2ab894d

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

sqlite_utils/db.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3004,9 +3004,6 @@ def build_insert_queries_and_params(
30043004
return a list of ``(sql, parameters)`` 2-tuples which, when executed in
30053005
order, perform the desired INSERT / UPSERT / REPLACE operation.
30063006
"""
3007-
if (upsert or replace) and not pk:
3008-
raise PrimaryKeyRequired("UPSERT / REPLACE needs a primary key")
3009-
30103007
if hash_id_columns and hash_id is None:
30113008
hash_id = "id"
30123009

@@ -3319,8 +3316,6 @@ def insert_all(
33193316
if hash_id_columns and hash_id is None:
33203317
hash_id = "id"
33213318

3322-
if upsert and (not pk and not hash_id):
3323-
raise PrimaryKeyRequired("upsert() requires a pk")
33243319
assert not (hash_id and pk), "Use either pk= or hash_id="
33253320
if hash_id_columns and (hash_id is None):
33263321
hash_id = "id"

0 commit comments

Comments
 (0)