.save() is throwing duplicate key value violates unique constraint on Postgresql
Problem
Issue Description When trying to upsert an entity to a Postgresql DB, I get a `QueryFailedError: duplicate key value violates unique constraint`. Expected Behavior I currently have a simple case : [code block]` Where the User entity is defined as such : [code block]` Actual Behavior [code block]` with a `QueryFailedError: duplicate key value violates unique constraint`. Steps to Reproduce A simple typeorm + Postgresql stack should suffice My Environment I'm on a plain TS stack, nothing fancy atm. Relevant Database Driver(s) - [ ] `aurora-data-api` - [ ] `aurora-data-api-pg` - [ ] `better-sqlite3` - [ ] `cockroachdb` - [ ] `cordova` - [ ] `expo` - [ ] `mongodb` - [ ] `mysql` - [ ] `nativescript` - [ ] `oracle` - [x] `postgres` - [ ] `react-native` - [ ] `sap` - [ ] `sqlite` - [ ] `sqlite-abstract` - [ ] `sqljs` - [ ] `sqlserver` Are you willing to resolve this issue by submitting a Pull Request? - [ ] Yes, I have the time, and I know how to start. - [x] Yes, I have the time, but I don't know how to start. I would need guidance. - [ ] No, I don't have the time, although I believe I could do it if I had the time... - [ ] No, I don't have the time and I wouldn't even know how to start.
Error Output
Error: duplicate key value violates unique constraint`.
0 Fixes
No verified fix yet
This issue has been reported but no fix has been submitted or verified. If you have solved this problem, share your solution to help others.
Candidate Fixes
Fixes from related issues โ may apply here too.
Be able to update or retrieve a single record including non-unique fields in the "where" conditions.
Enhance Update Query to Support Non-Unique Fields
Support querying across multiple schemas
Enable Cross-Schema Queries in Prisma
MongoDB support for Prisma 2+
Enable MongoDB Support in Prisma 2+
Make cuid2 available in `@default`
Integrate cuid2 as Default ID Generator in Prisma
Conditional uniqueness constraints; Partial/Filtered (Unique) Indexes
Implement Conditional Uniqueness Constraints in Prisma
Environment
Submitted by
Alex Chen
2450 rep