Prisma-client-js: Some(WrongType ... Type(Uuid)) error

Created on 20 Feb 2020  路  17Comments  路  Source: prisma/prisma-client-js

Hey 馃憢 ,

I am trying to create an instance in the database and also provide an id field data.

_model:_

model locations {
  id        String   @id
  latitude  Float
  longitude Float
  tweets    tweets[]
}

_error:_

prisma-client Requests: +111ms
  prisma-client [
  prisma-client   'mutation {\n' +
  prisma-client     '  createOnelocations(data: {\n' +
  prisma-client     '    id: "f70c6744-c2cb-5a28-b4c6-5aa0680dac0c"\n' +
  prisma-client     '    latitude: 211635869109.4528\n' +
  prisma-client     '    longitude: -352645828260.6592\n' +
  prisma-client     '  }) {\n' +
  prisma-client     '    id\n' +
  prisma-client     '    latitude\n' +
  prisma-client     '    longitude\n' +
  prisma-client     '  }\n' +
  prisma-client     '}'
  prisma-client ] +0ms
  prisma-client Results: +593ms
  prisma-client [
  prisma-client   PrismaClientUnknownRequestError: Error occurred during query execution:
  prisma-client   ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: ToSql(0), cause: Some(WrongType { postgres: Type(Uuid), rust: "alloc::borrow::Cow<str>" }) }) })
  prisma-client       at NodeEngine.graphQLToJSError (/Users/maticzavadlal/Code/work/prisma/prisma-test-utils-automation/dbs/basic-twitter/node_modules/prisma-client/runtime/index.js:1:16029)
  prisma-client       at /Users/maticzavadlal/Code/work/prisma/prisma-test-utils-automation/dbs/basic-twitter/node_modules/prisma-client/runtime/index.js:1:14963
  prisma-client       at Array.map (<anonymous>)
  prisma-client       at /Users/maticzavadlal/Code/work/prisma/prisma-test-utils-automation/dbs/basic-twitter/node_modules/prisma-client/runtime/index.js:1:14930
  prisma-client       at processTicksAndRejections (internal/process/task_queues.js:97:5)
  prisma-client       at Dataloader.loader (/Users/maticzavadlal/Code/work/prisma/prisma-test-utils-automation/dbs/basic-twitter/node_modules/prisma-client/index.js:55:23)
  prisma-client ] +0ms
  prisma-client Error: Error occurred during query execution:
  prisma-client ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: ToSql(0), cause: Some(WrongType { postgres: Type(Uuid), rust: "alloc::borrow::Cow<str>" }) }) })
  prisma-client     at NodeEngine.graphQLToJSError (/Users/maticzavadlal/Code/work/prisma/prisma-test-utils-automation/dbs/basic-twitter/node_modules/prisma-client/runtime/index.js:1:16029)
  prisma-client     at /Users/maticzavadlal/Code/work/prisma/prisma-test-utils-automation/dbs/basic-twitter/node_modules/prisma-client/runtime/index.js:1:14963
  prisma-client     at Array.map (<anonymous>)
  prisma-client     at /Users/maticzavadlal/Code/work/prisma/prisma-test-utils-automation/dbs/basic-twitter/node_modules/prisma-client/runtime/index.js:1:14930
  prisma-client     at processTicksAndRejections (internal/process/task_queues.js:97:5)
  prisma-client     at Dataloader.loader (/Users/maticzavadlal/Code/work/prisma/prisma-test-utils-automation/dbs/basic-twitter/node_modules/prisma-client/index.js:55:23) +3ms
bu2-confirmed kinbug statuneeds-action types

Most helpful comment

~I am unable to boot the script :/,~
~image~

Update: I read the code, I need to create introspection results first using index.js. Debugging this further now.

All 17 comments

What code are you executing exactly?

Could not reproduce: https://github.com/janpio/repro512
What are you doing differently?
(Same result with a local PostgreSQL db)

@maticzav If you share the SQL dump of the database, that would be useful for triaging this.

@janpio try running src/test.ts in prisma-test-utils-automation. I also set up a debugging environment there.

To reproduce: pull, install dependencies and yarn ts-node src/test.ts

@pantharshit00 Matic refers to https://github.com/prisma/prisma-test-utils-automation here, so if you have the time you could do what he suggested for me.

@pantharshit00 any progress with this one? I can't do much without your help here. 馃檪

@maticzav Could you please look into https://github.com/prisma/prisma-client-js/issues/512#issuecomment-589326658 and see where your code differs? Having a minimal reproduction is always much easier than "look into my giant project to figure it out" as I am sure you know.

@janpio I prepared a one-file reproduction with a debugger enabled. I am not sure how much further I can go with making reproduction more approachable. The difference with your case is in the production of id value. As described above and as I've asked in the Slack thread the problem I am having is with the id verification.

~I am unable to boot the script :/,~
~image~

Update: I read the code, I need to create introspection results first using index.js. Debugging this further now.

This is related to https://github.com/prisma/prisma2/issues/479

Right now the implementation of @id @default(uuid()) in postgres marks the database field as a text(See https://github.com/prisma/migrate/issues/114). The query engine uses an internal implementation of the UUID type. So when you introspect a UUID, the introspection engine maps it to a String @id, but the query engine does not understand the postgres UUID type so it panics. We ignored this in the past we are waiting on native database type support as mentioned in #47

So either you can change the database type from uuid to string or you will need to wait till we release support for postgres uuid in the query engine here.

We can close this as a duplicate but I don't know as this issue concerns an internal project.

@maticzav Workaround for now: Do not use/support UUID types.

Let's keep this around @pantharshit00, as it shows the exact outcome in Prisma Client. Also might be tackled outside of context of other native database types work.

@janpio @pantharshit00 this is an introspection result - how can I determine which schemas use uuid and which don't?

this is an introspection result - how can I determine which schemas use uuid and which don't?

You can use a GUI like https://tableplus.io to see the postgres schema. It is a bit of manual work though.

how can I determine which schemas use uuid and which don't?

Besides manually you can not really, and these schemas failing is exactly what we want to find out with test-utils so I would say this is fine for now. Make it work with other schemas that do not have this (e.g. MySQL)

This is fixed in the latest version.

Was this page helpful?
0 / 5 - 0 ratings