Prisma thinks named relation - @ralation (name:..) - is a field with unique constraint #12085
Labels
bug/1-unconfirmed
Bug should have enough information for reproduction, but confirmation has not happened yet.
kind/bug
A reported bug.
team/schema
Issue for team Schema.
topic: relations
Bug description
Prisma considers field with named relation
@relation(name: "MyRelation", fields:[]...)
as field with unique constraint, even though I have not defined themas unique.Hence when I try to insert a new record that references same FK, it fails with unique constraint violation.
For example the following model:
Generates the following code:
and
How to reproduce
schema.prisma
with named relations, e.g.npm prisma generate
CREATE UNIQUE INDEX
index.d.ts
forOrgFacilityEmissionSourceWhereUniqueInput
that includesactivitySourceUid
as one of the fields for unique input.Expected behavior
Unless explicitly declared as @unique,
prima generate
should not generate code that handles those fields as unique.Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: