# HG changeset patch # User Goffi # Date 1558594709 -7200 # Node ID 724e39d596a967fe15cbb1f114b375f7f4c95aef # Parent 907b1048039449aadc885bde6b86e677633b6a59 psql: use a set for categories, to avoid duplicates (and constraint failure) diff -r 907b10480394 -r 724e39d596a9 src/pgsql_storage.py --- a/src/pgsql_storage.py Tue May 07 09:15:20 2019 +0200 +++ b/src/pgsql_storage.py Thu May 23 08:58:29 2019 +0200 @@ -958,7 +958,8 @@ cursor.execute("""DELETE FROM item_categories WHERE item_id=%s""", (item_id,)) - for category in categories: + # we use a set to avoid duplicates + for category in set(categories): cursor.execute("""INSERT INTO item_categories (item_id, category) VALUES (%s, %s)""", (item_id, category))