Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prisma incorrectly parses CRDB's FK constraint error as not available #24072

Open
evangeline opened this issue May 3, 2024 · 1 comment
Open
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: cockroachdb topic: error topic: foreign keys

Comments

@evangeline
Copy link

evangeline commented May 3, 2024

Bug description

We are seeing errors like

Foreign key constraint failed on the field: `(not available)`

and was wondering whether it’s possible to surface which FK is causing this error. Some tables have multiple FKs, and (not available) makes it harder to narrow down which FK is throwing.

When running the query manually, CRDB throws the following error, which suggests that Prisma is not parsing the FK name correctly.

ERROR: insert on table "WearablePart" violates foreign key constraint "WearablePart_wearableId_fkey" Detail: Key (wearableId)=('foo') is not present in table "Wearable".

How to reproduce

  1. Create a table with a FK constraint in CRDB
  2. Insert data with an invalid foreign key via Prisma
  3. Insert the same data via cockroach sql or any other DB client

Expected behavior

I would expect to see the error

Foreign key constraint failed on the field: `WearablePart_wearableId_fkey`

Prisma information

Fails on any schema, repro steps above.

Environment & setup

  • OS: macOS
  • CockroachDB
  • Node.js version: v18.17.0

Prisma Version

v5.9.1
@evangeline evangeline added the kind/bug A reported bug. label May 3, 2024
@SevInf SevInf added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. topic: error team/client Issue for team Client. topic: foreign keys labels May 3, 2024
@janpio
Copy link
Member

janpio commented May 6, 2024

Can you maybe create a reproduction repository that we can just run to experience this problem? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: cockroachdb topic: error topic: foreign keys
Projects
None yet
Development

No branches or pull requests

4 participants