aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-04-28 13:01:20 -0500
committerFrederick Muriuki Muriithi2025-04-28 13:01:20 -0500
commit791a6e67d93bbea35fc86f228a8d0387bb4335ad (patch)
treead6297ff5690372a8b2974e055ce7b03946cd2bc
parent29177392613cab26d6402bf8f63f42096aee1c9d (diff)
downloadgn-uploader-791a6e67d93bbea35fc86f228a8d0387bb4335ad.tar.gz
Do not auto-update publication details on conflict
Auto-update of a publication's details on an "insert conflict" would lead to a bug where publications could be overwritten with the wrong information. Rather than auto-update, explicitly indicate the error, and let the user manually edit the record to avoid data inconsistency.
-rw-r--r--uploader/publications/models.py7
1 files changed, 1 insertions, 6 deletions
diff --git a/uploader/publications/models.py b/uploader/publications/models.py
index 7d2862d..8dd62f3 100644
--- a/uploader/publications/models.py
+++ b/uploader/publications/models.py
@@ -42,15 +42,10 @@ def create_new_publications(
"%(pubmed_id)s, %(abstract)s, %(authors)s, %(title)s, "
"%(journal)s, %(volume)s, %(pages)s, %(month)s, %(year)s"
") "
- "ON DUPLICATE KEY UPDATE "
- "Abstract=VALUES(Abstract), Authors=VALUES(Authors), "
- "Title=VALUES(Title), Journal=VALUES(Journal), "
- "Volume=VALUES(Volume), Pages=VALUES(pages), "
- "Month=VALUES(Month), Year=VALUES(Year) "
"RETURNING *"),
publications)
return tuple({
- **row, "PublicationId": row["Id"]
+ **row, "publication_id": row["Id"]
} for row in cursor.fetchall())
return tuple()