Skip to content
This repository was archived by the owner on Jan 14, 2021. It is now read-only.
This repository was archived by the owner on Jan 14, 2021. It is now read-only.

PrismaClientUnknownRequestError - InterpretationError on nested create #605

@MichalLytek

Description

@MichalLytek

Bug description

When I try to save entity that has required relation to other entity, Prisma throws unhelpful an error when connect or create is used:

Debug logs:

DEBUG="*" npx ts-node --transpile-only test.ts
  prisma-client {
  prisma-client   engineConfig: {
  prisma-client     cwd: 'D:\\#Projekty\\typegraphql-prisma\\experiments\\prisma',
  prisma-client     debug: false,
  prisma-client     datamodelPath: 'D:\\#Projekty\\typegraphql-prisma\\experiments\\prisma\\generated\\client\\schema.prisma',
  prisma-client     prismaPath: undefined,
  prisma-client     datasources: [ [Object] ],
  prisma-client     generator: {
  prisma-client       name: 'client',
  prisma-client       provider: 'prisma-client-js',
  prisma-client       output: 'D:\\#Projekty\\typegraphql-prisma\\experiments\\prisma\\generated\\client',
  prisma-client       binaryTargets: [Array],
  prisma-client       config: {},
  prisma-client       documentation: 'binaryTargets = ["windows", "debian-openssl-1.1.x"]\r'
  prisma-client     },
  prisma-client     showColors: false,
  prisma-client     logLevel: 'info',
  prisma-client     logQueries: true,
  prisma-client     env: {},
  prisma-client     flags: []
  prisma-client   }
  prisma-client } +0ms
  prisma-client Prisma Client call: +41ms
  prisma-client prisma.post.create({
  prisma-client   data: {
  prisma-client     title: 'Post title 1',
  prisma-client     content: 'Content 1',
  prisma-client     kind: 'BLOG',
  prisma-client     createdAt: new Date('2019-08-16T00:00:00.000Z'),
  prisma-client     published: true,
  prisma-client     updatedAt: new Date('2019-08-17T00:00:00.000Z'),
  prisma-client     author: {
  prisma-client       create: {
  prisma-client         age: 50,
  prisma-client         amount: 123,
  prisma-client         balance: 0,
  prisma-client         email: '[email protected]',
  prisma-client         name: 'Test',
  prisma-client         role: 'ADMIN'
  prisma-client       }
  prisma-client     }
  prisma-client   }
  prisma-client }) +1ms
  prisma-client Generated request: +7ms
  prisma-client mutation {
  prisma-client   createOnePost(data: {
  prisma-client     title: "Post title 1"
  prisma-client     content: "Content 1"
  prisma-client     kind: BLOG
  prisma-client     createdAt: "2019-08-16T00:00:00.000Z"
  prisma-client     published: true
  prisma-client     updatedAt: "2019-08-17T00:00:00.000Z"
  prisma-client     author: {
  prisma-client       create: {
  prisma-client         age: 50
  prisma-client         amount: 123
  prisma-client         balance: 0
  prisma-client         email: "[email protected]"
  prisma-client         name: "Test"
  prisma-client         role: ADMIN
  prisma-client       }
  prisma-client     }
  prisma-client   }) {
  prisma-client     uuid
  prisma-client     createdAt
  prisma-client     updatedAt
  prisma-client     published
  prisma-client     title
  prisma-client     content
  prisma-client     kind
  prisma-client   }
  prisma-client }
  prisma-client  +0ms
  getos { platform: 'win32', libssl: undefined } +0ms
  engine {
  engine   PRISMA_DML_PATH: 'D:\\#Projekty\\typegraphql-prisma\\experiments\\prisma\\generated\\client\\schema.prisma',
  engine   PORT: '56440',
  engine   RUST_BACKTRACE: '1',
  engine   RUST_LOG: 'info',
  engine   LOG_QUERIES: 'true',
  engine   OVERWRITE_DATASOURCES: '[{"name":"db","url":"file:D:\\\\#Projekty\\\\typegraphql-prisma\\\\experiments\\\\dev.db"}]'
  engine } +0ms
  engine { cwd: 'D:\\#Projekty\\typegraphql-prisma\\experiments\\prisma' } +3ms
  engine { flags: [ '--enable-raw-queries' ] } +2ms
  engine stderr Printing to stderr for debugging +14ms
  engine stderr Listening on 127.0.0.1:56440 +1ms
  engine stdout {
  timestamp: 'Mar 28 18:10:39.564',
  level: 'INFO',
  target: 'quaint::pooled',
  fields: { message: 'Starting a sqlite pool with 13 connections.' }
} +4ms
prisma:info  Starting a sqlite pool with 13 connections.
  engine stdout {
  timestamp: 'Mar 28 18:10:39.570',
  level: 'INFO',
  target: 'prisma::server',
  fields: {
    message: 'Started http server on 127.0.0.1:56440',
    'log.target': 'prisma::server',
    'log.module_path': 'prisma::server',
    'log.file': 'query-engine/prisma/src/server.rs',
    'log.line': 109
  }
} +5ms
prisma:info  Started http server on 127.0.0.1:56440
  engine stdout {
  timestamp: 'Mar 28 18:10:39.584',
  level: 'INFO',
  target: 'quaint::connector::metrics',
  fields: { query: 'BEGIN', item_type: 'query', params: '[]', duration_ms: 0 }
} +14ms
prisma:query BEGIN
  engine stdout {
  timestamp: 'Mar 28 18:10:39.587',
  level: 'INFO',
  target: 'quaint::connector::metrics',
  fields: {
    query: 'INSERT INTO `dev`.`User` (`email`, `name`, `age`, `balance`, `amount`, `role`) VALUES (?,?,?,?,?,?)',
    item_type: 'query',
    params: '["[email protected]","Test",50,0,123,"ADMIN"]',
    duration_ms: 2
  }
} +3ms
prisma:query INSERT INTO `dev`.`User` (`email`, `name`, `age`, `balance`, `amount`, `role`) VALUES (?,?,?,?,?,?)
  engine stdout {
  timestamp: 'Mar 28 18:10:39.591',
  level: 'INFO',
  target: 'quaint::connector::metrics',
  fields: {
    query: 'ROLLBACK',
    item_type: 'query',
    params: '[]',
    duration_ms: 3
  }
} +4ms
prisma:query ROLLBACK
  engine {
  engine   error: PrismaClientUnknownRequestError: Error occurred during query execution:
  engine   InterpretationError("Error for binding \'1\': DomainError(ConversionFailure(\"record identifier\", \"assimilated record identifier\"))")
  engine       at NodeEngine.graphQLToJSError (D:\#Projekty\typegraphql-prisma\experiments\prisma\generated\client\runtime\index.js:1:18853)
  engine       at D:\#Projekty\typegraphql-prisma\experiments\prisma\generated\client\runtime\index.js:1:16340
  engine       at processTicksAndRejections (internal/process/task_queues.js:97:5)
  engine       at Dataloader.loader (D:\#Projekty\typegraphql-prisma\experiments\prisma\generated\client\runtime\index.js:1:50649)
  engine } +4ms
  printStack callsite Error
    at Object.s [as Post] (D:\#Projekty\typegraphql-prisma\experiments\prisma\generated\client\runtime\index.js:1:48553)
    at Object.n.<computed> [as create] (D:\#Projekty\typegraphql-prisma\experiments\prisma\generated\client\runtime\index.js:1:50179)
    at main (D:\#Projekty\typegraphql-prisma\experiments\test.ts:8:23)
    at Object.<anonymous> (D:\#Projekty\typegraphql-prisma\experiments\test.ts:30:1)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)
    at Module.m._compile (D:\#Projekty\typegraphql-prisma\experiments\node_modules\ts-node\src\index.ts:837:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Object.require.extensions.<computed> [as .ts] (D:\#Projekty\typegraphql-prisma\experiments\node_modules\ts-node\src\index.ts:840:12)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14) +0ms
PrismaClientUnknownRequestError:
Invalid `prisma.post.create()` invocation in
D:\#Projekty\typegraphql-prisma\experiments\test.ts:8:23

   4   log: ["query", "info", "warn"],
   5 });
   6
   7 async function main() {
→  8   await prisma.post.create(

Error occurred during query execution:
InterpretationError("Error for binding \'1\': DomainError(ConversionFailure(\"record identifier\", \"assimilated record identifier\"))")
    at PrismaClientFetcher.request (D:\#Projekty\typegraphql-prisma\experiments\prisma\generated\client\runtime\index.js:1:51487)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
  engine Stopping Prisma engine +18ms
  getos { platform: 'win32', libssl: undefined } +79ms

How to reproduce

Try to add some entity with nested create or connect:

 await prisma.post.create({
    data: {
      title: "Post title 1",
      content: "Content 1",
      kind: "BLOG",
      createdAt: new Date("2019-08-16"),
      published: true,
      updatedAt: new Date("2019-08-17"),
      author: {
        create: {
          age: 50,
          amount: 123,
          balance: 0,
          email: "[email protected]",
          name: "Test",
          role: "ADMIN",
        },
      },
    },
  });

Expected behavior

It should insert the data without throwing an error.

Prisma information

model User {
  id      Int     @id @default(autoincrement())
  email   String  @unique
  name    String?
  age     Int
  balance Numeric
  amount  Float
  posts   Post[]
  role    Role
}

enum PostKind {
  BLOG
  ADVERT
}

model Post {
  uuid      String    @default(uuid()) @id
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
  published Boolean
  title     String
  content   String?
  author    User
  kind      PostKind?
}

Environment & setup

  • OS: [e.g. Mac OS, Windows, Debian, CentOS, ...] Win 10 x64
  • Database: [PostgreSQL, MySQL, MariaDB or SQLite] SQLite
  • Prisma version: [Run prisma2 -v to see your Prisma version] alpha 980
  • Node.js version: [Run node -v to see your Node.js version] 13.11

Metadata

Metadata

Assignees

Labels

bug/1-repro-availableA reproduction exists and needs to be confirmed.kind/bugA reported bug.tech/enginesIssue for tech Engines.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions