From 2b20a5d69fea6241c630a93f5e50233da2b2909b Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Sun, 8 May 2022 15:25:11 +0200 Subject: [PATCH] Update line details on reimport conflict. To deal with misnamed lines. Fixes #240. --- bin/datastore.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/datastore.py b/bin/datastore.py index cb1f52e..a7f2223 100644 --- a/bin/datastore.py +++ b/bin/datastore.py @@ -412,7 +412,11 @@ class Datastore: qry = """ INSERT INTO raw_lines (sequence, line, remarks, ntbp, incr, meta) VALUES (%s, %s, '', %s, %s, %s) - ON CONFLICT DO NOTHING; + ON CONFLICT (sequence) DO UPDATE SET + line = EXCLUDED.line, + ntbp = EXCLUDED.ntbp, + incr = EXCLUDED.incr, + meta = EXCLUDED.meta; """ cursor.execute(qry, (fileinfo["sequence"], fileinfo["line"], ntbp, incr, json.dumps(fileinfo["meta"]))) @@ -462,7 +466,9 @@ class Datastore: qry = """ INSERT INTO final_lines (sequence, line, remarks, meta) VALUES (%s, %s, '', %s) - ON CONFLICT DO NOTHING; + ON CONFLICT (sequence) DO UPDATE SET + line = EXCLUDED.line, + meta = EXCLUDED.meta; """ cursor.execute(qry, (fileinfo["sequence"], fileinfo["line"], json.dumps(fileinfo["meta"])))