Prisma-client-js: Error when creating a record with relations: syntax error at or near ")"

Created on 31 Mar 2020  路  5Comments  路  Source: prisma/prisma-client-js

Bug description

When I create a record that has a relation, I get the following error:

Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("42601"), message: "syntax error at or near \")\"", detail: None, hint: None, position: Some(Original(57)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("scan.l"), line: Some(1145), routine: Some("scanner_yyerror") }) }) })
    at PrismaClientFetcher.request (/home/oden/Dev/Templates/test/node_modules/@prisma/client/runtime/index.js:1:51485)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

How to reproduce

I created a minimal repro to demonstrate the issue: https://github.com/odensc/prisma-repro

  1. Clone the repo
  2. Create the Postgres database and table
  3. npm install
  4. prisma2 migrate up --experimental
  5. node index.js
  6. The script should error.

Seems like the issue is here:

prisma:query SELECT "public"."Post"."id" FROM "public"."Post" WHERE () IN (($1)) OFFSET $2

You can see the WHERE parameter list is empty.

Expected behavior

The create call should work and returns the new record.

Prisma information

All included in the repo.

Environment & setup

  • OS: Arch Linux
  • Database: Postgres 12.2
  • Prisma version: 2.0.0-beta.1
  • Node.js version: 13.8.0
bu2-confirmed kinbug

Most helpful comment

I traced this back to the breaking relation change in 2.0.0-beta.1.

Apparently I decided to start fiddling around literally minutes after 2.0.0-beta.1 was released, but before the GitHub docs were redirected to prisma.io - so I was working off the old documentation regarding relations. Just unlucky :)

So I suppose the real issue is that the error message could be more helpful :+1: Would you prefer I open a new issue for that, or edit this one?

All 5 comments

Same error as #578 it seems but different data model.

I traced this back to the breaking relation change in 2.0.0-beta.1.

Apparently I decided to start fiddling around literally minutes after 2.0.0-beta.1 was released, but before the GitHub docs were redirected to prisma.io - so I was working off the old documentation regarding relations. Just unlucky :)

So I suppose the real issue is that the error message could be more helpful :+1: Would you prefer I open a new issue for that, or edit this one?

This will be fixed once we have improved the validation of @relation. Currently the schema validation does not fail when fields is required but not specified.

You should get an error during generate now.

@janpio Can confirm. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AhmedElywa picture AhmedElywa  路  4Comments

samrith-s picture samrith-s  路  3Comments

maartenraes picture maartenraes  路  4Comments

FluorescentHallucinogen picture FluorescentHallucinogen  路  3Comments

divyenduz picture divyenduz  路  3Comments