go-gorm / playground

GORM Playground (Please Create PR for this project to report issues)
MIT License
89 stars 678 forks source link

'Duplicate entry' while Save() composite primary key model #664

Open YianAndCode opened 9 months ago

YianAndCode commented 9 months ago

I have a table using a composite primary key. When one of the primary key fields in a record in the database has a value of 0, after I modify this record and then use Save() to save the model, gorm is unable to correctly handle this as an UPDATE operation, but instead uses INSERT, leading to a Duplicate entry error.