prisma / prisma-test-utils

A collection of data model agnostic test utils.
114 stars 11 forks source link

Got invalid value, support for scalar arrays #31

Closed divyenduz closed 4 years ago

divyenduz commented 4 years ago

~Note: I have only seen this for strings so far but this might also apply to all scalar lists.~ Saw another case for Int type.

Note: So far, I have only seen this happening in Postgres. I think we removed scalar lists when not natively supported by the database (TODO: confirm this).

Example: query generated by prisma-test-utils for this table:

2020-03-09T10:53:06.228Z printStack callsite undefined
2020-03-09T10:53:06.230Z printStack callsite Error
    at new room_aliasesClient (/home/runner/work/introspection-engine-output/introspection-engine-output/clients/postgresql_public_test_utils/ruma/index.js:3159:21)
    at Object.room_aliases.create (/home/runner/work/introspection-engine-output/introspection-engine-output/clients/postgresql_public_test_utils/ruma/index.js:3041:7)
    at /home/runner/work/introspection-engine-output/prisma-test-utils/src/static/seed.ts:924:45
    at Generator.next (<anonymous>)
    at /home/runner/work/introspection-engine-output/prisma-test-utils/dist/static/seed.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/home/runner/work/introspection-engine-output/prisma-test-utils/dist/static/seed.js:4:12)
    at iterate (/home/runner/work/introspection-engine-output/prisma-test-utils/dist/static/seed.js:633:24)
    at /home/runner/work/introspection-engine-output/prisma-test-utils/src/static/seed.ts:947:30
    at Generator.next (<anonymous>)
PrismaClientValidationError: 
Invalid `prisma.room_aliases.create()` invocation in
/home/runner/work/introspection-engine-output/introspection-engine-output/clients/postgresql_public_test_utils/ruma/index.js:3041:7

{
  data: {
    alias: '09be360b-3c5d-56e2-9564-196a9e00a912',
    created_at: new Date('2082-02-10T06:10:11.646Z'),
    room_id: 'lejaj',
    servers: 'ulbihmu',
             ~~~~~~~~~
    updated_at: new Date('2089-08-09T03:07:54.076Z'),
    user_id: 'okotukov'
  }
}

Argument servers: Got invalid value 'ulbihmu' on prisma.createOneroom_aliases. Provided String, expected room_aliasesCreateserversInput:
type room_aliasesCreateserversInput {
  set?: List<String>
}

Internal notes:

Test utils database(s) affected:

The type of field in discource is inet though. Should it map back to be a string?

maticzav commented 4 years ago

@divyenduz test-utils don’t support scalar lists because I couldn’t find documentation for it. Is it available yet?

divyenduz commented 4 years ago

Yes, I think here: https://github.com/prisma/prisma2/blob/master/docs/prisma-client-js/api.md#scalar-lists

maticzav commented 4 years ago

Supported in the last version.

divyenduz commented 4 years ago

I still get the same query built (string in place of scalar array) when I use test-utils from master!

maticzav commented 4 years ago

@divyenduz I cannot reproduce. Have you, by chance, forgot to rebuild runtime and build files?

Screenshot 2020-03-11 at 14 04 19
divyenduz commented 4 years ago

Yes, you are correct, I was on an older branch! Sorry for the false alarm. CI is spinning again! Will reopen, if the problem persists :)