From 791a6e67d93bbea35fc86f228a8d0387bb4335ad Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 28 Apr 2025 13:01:20 -0500 Subject: 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. --- uploader/publications/models.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'uploader/publications/models.py') 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() -- cgit v1.2.3