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
upsert(): Unique constraint on DateTime sqlite #14584
Comments
Will calling |
I cannot reproduce this in any way. That doesn't mean it is not an issue, because I can for sure reproduce other similar issues. I tried to take the inputs from here and use them in the reproduction of the other similar issue. Never got any errors with this data model. I still highly consider this bug to exist. Whoever is fixing it should take a reproduction from the other similar issues for testing. |
Prisma Upserts are very powerful and support very nested upserts. This can lead to a Unique constraint error being thrown. We have updated our docs with why this happens and what to do in that situation. |
I believe I have a similar case:
Error:Unique constraint failed on the fields: (`deviceId`,`timestamp`)
at fn.handleRequestError (C:\Users\basti\Desktop\ttn-grafana-stack\ttnmapper-reader\node_modules\.pnpm\@prisma+client@4.12.0_prisma@4.12.0\node_modules\@prisma\client\runtime\library.js:174:6477)
at fn.handleAndLogRequestError (C:\Users\basti\Desktop\ttn-grafana-stack\ttnmapper-reader\node_modules\.pnpm\@prisma+client@4.12.0_prisma@4.12.0\node_modules\@prisma\client\runtime\library.js:174:5907)
at fn.request (C:\Users\basti\Desktop\ttn-grafana-stack\ttnmapper-reader\node_modules\.pnpm\@prisma+client@4.12.0_prisma@4.12.0\node_modules\@prisma\client\runtime\library.js:174:5786)
at async t._request (C:\Users\basti\Desktop\ttn-grafana-stack\ttnmapper-reader\node_modules\.pnpm\@prisma+client@4.12.0_prisma@4.12.0\node_modules\@prisma\client\runtime\library.js:177:10477)
at async Function.getNewTTNMapperDataForSubscribedDevices (C:\Users\basti\Desktop\ttn-grafana-stack\ttnmapper-reader\src\scheduledFunctions\getNewTTNMapperData.ts:29:44) {
code: 'P2002',
clientVersion: '4.12.0',
meta: { target: [ 'deviceId', 'timestamp' ] }
} |
I fixed it by adding |
That would be amazing. Please post it as a new issue, that is much easier for us to handle. Thanks! |
Bug description
How to reproduce
I have an analytics model which increments a count of whenever a user clicks on a certain contact method.
Expected behavior
When calling this upsert function, the correct method is incremented
Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: