diff --git a/metasvc-server/backend-jdbi/src/main/resources/io/github/dbmdz/metadata/server/backend/impl/database/migration/R__func_subjects_is_unique_type_identifier.sql b/metasvc-server/backend-jdbi/src/main/resources/io/github/dbmdz/metadata/server/backend/impl/database/migration/R__func_subjects_is_unique_type_identifier.sql index 086404183..3e53240f8 100644 --- a/metasvc-server/backend-jdbi/src/main/resources/io/github/dbmdz/metadata/server/backend/impl/database/migration/R__func_subjects_is_unique_type_identifier.sql +++ b/metasvc-server/backend-jdbi/src/main/resources/io/github/dbmdz/metadata/server/backend/impl/database/migration/R__func_subjects_is_unique_type_identifier.sql @@ -14,7 +14,7 @@ declare tuple_exists boolean; begin if ids is null or cardinality(ids) = 0 then - execute 'select exists(select 1 from public.subjects where $1 = type and $2 = label and $3 <> uuid)' + execute 'select exists(select 1 from public.subjects where $1 = type and $2 = label and coalesce(identifiers, array[]::dbidentifier[]) = array[]::dbidentifier[] and $3 <> uuid)' into tuple_exists using ptype, plabel, puuid; if tuple_exists then