Wrong typing when trying to connect models with a unique constraint on an optional field #24032
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: client types
Types in Prisma Client
topic: (@)@unique
Bug description
We have a model that has an optional field that has to be unique. When trying to use the
connect
keyword we get a TS error that the optional field does not have the right type.A full reproduction repo can be found here: https://github.com/vdhpieter/prisma-partial-uniqueness-bug
How to reproduce
These reproductions start from a reproduction repo after following: https://www.prisma.io/docs/getting-started/quickstart
name
field unique in your schema for the User model:https://github.com/vdhpieter/prisma-partial-uniqueness-bug/blob/c23577bc4a6050d6132f032a45b2ccb63ebd7f45/prisma/schema.prisma#L16
https://github.com/vdhpieter/prisma-partial-uniqueness-bug/blob/c23577bc4a6050d6132f032a45b2ccb63ebd7f45/script.ts#L6-L8
https://github.com/vdhpieter/prisma-partial-uniqueness-bug/blob/c23577bc4a6050d6132f032a45b2ccb63ebd7f45/script.ts#L10-L13
npm run start
)https://github.com/vdhpieter/prisma-partial-uniqueness-bug/blob/c23577bc4a6050d6132f032a45b2ccb63ebd7f45/script.ts#L14-L21
Expected behavior
I can use connect with models that have optional unique fields.
Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: