prisma / prisma-test-utils

A collection of data model agnostic test utils.
112 stars 10 forks source link

Unique constraint failed on the fields: (`npi`) #26

Open janpio opened 4 years ago

janpio commented 4 years ago

When using prisma-test-utils via prisma-test-utils-automation, some databases (schemas from: prisma/database-schema-examples) fail with this error message:

Error in: cms-utilization-db (postgres)
PrismaClientKnownRequestError:
Invalid `: new providersClient()` invocation in
C:\Users\Jan\Documents\prisma-test-utils-automation\dbs\cms-utilization-db\node_modules\prisma-client\index.js:846:7

   842   args || {},
   843   [],
   844   errorFormat,
   845   measurePerformance
→  846 ) : new providersClient

Unique constraint failed on the fields: (`npi`)
    at PrismaClientFetcher.request (C:\Users\Jan\Documents\prisma-test-utils-automation\dbs\cms-utilization-db\node_modules\prisma-client\index.js:87:17)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  code: 'P2002',
  meta: { target: [ 'npi' ] }
}

SQL for the providers table:

create table providers
(
        npi integer not null
                constraint providers_npi_pk
                        primary key,
        entity_type text,
        provider_type text,
        address_street_01 text,
        address_street_02 text,
        address_city text,
        address_zip_code text,
        address_state text,
        address_country text,
        address_latitude numeric,
        address_longitude numeric
)
;

Strange as it is clearly a PK here.

janpio commented 4 years ago
Error in: sakila
PrismaClientKnownRequestError:
Invalid `: new actorClient()` invocation in
C:\Users\Jan\Documents\prisma-test-utils-automation\dbs\sakila\node_modules\prisma-client\index.js:637:7

   633   args || {},
   634   [],
   635   errorFormat,
   636   measurePerformance
→  637 ) : new actorClient

Unique constraint failed on the fields: (`actor_id`)
    at PrismaClientFetcher.request (C:\Users\Jan\Documents\prisma-test-utils-automation\dbs\sakila\node_modules\prisma-client\index.js:87:17)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  code: 'P2002',
  meta: { target: [ 'actor_id' ] }
}