Mercurial > hg > orthanc-databases
changeset 438:f790232b77ef pg-transactions
fix InsertOrUpdateMetadata
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 18 Dec 2023 19:17:09 +0100 |
parents | d979f25e60cf |
children | 2bc65c678b1b |
files | PostgreSQL/Plugins/SQL/PrepareIndexV2.sql |
diffstat | 1 files changed, 2 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/PostgreSQL/Plugins/SQL/PrepareIndexV2.sql Mon Dec 18 18:50:01 2023 +0100 +++ b/PostgreSQL/Plugins/SQL/PrepareIndexV2.sql Mon Dec 18 19:17:09 2023 +0100 @@ -453,7 +453,8 @@ BEGIN FOR i IN 1 .. ARRAY_LENGTH(resource_ids, 1) LOOP -- RAISE NOTICE 'Parameter %: % % %', i, resource_ids[i], metadata_types[i], metadata_values[i]; - INSERT INTO Metadata VALUES(resource_ids[i], metadata_types[i], metadata_values[i], revisions[i]) ON CONFLICT DO NOTHING; + INSERT INTO Metadata VALUES(resource_ids[i], metadata_types[i], metadata_values[i], revisions[i]) + ON CONFLICT (id, type) DO UPDATE SET value = EXCLUDED.value, revision = EXCLUDED.revision; END LOOP; END;