From ac9f8208c7d24b92c983ea7d0f23545904a20e1d Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 8 May 2025 19:19:43 -0700 Subject: [PATCH] Put PrimaryKeyRequired back in the right place --- sqlite_utils/db.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index 2b43af6..89648e8 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -3316,6 +3316,9 @@ 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"