From 2ab894dd73f0f14a30edcd643283824a04836570 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 8 May 2025 19:15:46 -0700 Subject: [PATCH] Remove upsert() requires a pk checks --- sqlite_utils/db.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index b960790..2b43af6 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -3004,9 +3004,6 @@ class Table(Queryable): return a list of ``(sql, parameters)`` 2-tuples which, when executed in order, perform the desired INSERT / UPSERT / REPLACE operation. """ - if (upsert or replace) and not pk: - raise PrimaryKeyRequired("UPSERT / REPLACE needs a primary key") - if hash_id_columns and hash_id is None: hash_id = "id" @@ -3319,8 +3316,6 @@ class Table(Queryable): if hash_id_columns and hash_id is None: hash_id = "id" - if upsert and (not pk and not hash_id): - raise PrimaryKeyRequired("upsert() requires a pk") assert not (hash_id and pk), "Use either pk= or hash_id=" if hash_id_columns and (hash_id is None): hash_id = "id"