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 5.0 Migration findUnique
on @unique
columns that are enums
#20227
Comments
findUnique
on @unique
columns that are enums
findUnique
on @unique
columns that are enumsfindUnique
on @unique
columns that are enums
Same for us, the following code in Prisma 5 returns NULL, while the previous version of Prisma returns the correct value
Schema
|
So Do |
Query log:
Client engine log:
|
Prisma client even generates different sql Query Query when array.length > 1:
Query when array.length === 1:
|
Can confirm with the following schema: model model {
id String @id @default(uuid())
category Category @unique
}
enum Category {
A
B
} and the code: async function main() {
const prisma = new PrismaClient()
await prisma.model.deleteMany()
await prisma.model.create({
data: { category: 'A' },
})
const results = await Promise.all([
prisma.model.findUnique({ where: { category: 'A' } }),
prisma.model.findUnique({ where: { category: 'B' } }),
])
console.log(results)
} Happens on 5.0.0 and 4.16.2 with |
When JSON protocol is used and batching is happening, if the unique value is enum, we incorrectly compared the results with the inputs: inputs are PrismaValue::String, while outputs are PrismaValue::Enum. Fix prisma/prisma#20227
* qe: Fix batch results processing for enums When JSON protocol is used and batching is happening, if the unique value is enum, we incorrectly compared the results with the inputs: inputs are PrismaValue::String, while outputs are PrismaValue::Enum. Fix prisma/prisma#20227 * Fix mongo tests
Hello everyone. The fix is merged and will be a part of 5.1 release. If you want to test it before that, you can try |
@SevInf thanks for the quick responses and fix! I can confirm that the bug is fixed in the |
@SevInf do we have an estimated timeline for the 5.1.0 release? |
@jkepps Yes! 5.1.0 release is planned for Tuesday, August 1st. |
Yikes, just running into this in production. I thought I was going crazy. We are getting nulls where we are expecting full records. This happens as soon as an enum is included in an index.
Thanks for jumping on this quickly. For anyone getting this bug in production this could cause some pretty bad non intended consequences. In our example we could have sent notifications to all users that had their notifications turned off. @SevInf Any chance we can we get a bug patch before August? |
You can downgrade to previous Prisma version and disable JSONprotocol as a workaround |
@gkkirsch I too would suggest to hold off 5.x update until Tuesday in your case. |
Bug description
Given a schema:
After migrating to 5.0 our
findUnique
call for theFake
model withtype
returns null. If i switch tofindFirst
it will return the correct row.How to reproduce
have a model that has a
@unique
field that is an enum and run afindUnique
query against that column. Apologies if you're looking for a full repro I can try to put that together as well when I have more time, just wanted to get this report in asap.Expected behavior
I would expect that given the schema and models above with a row in the database that has the
type
ofabc
a query like the below would return that row:Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: