When a record is inserted with an assigned ID using db.Create(), that sequence ID is not committed.
Example: Given the sequence ID for user table is at ID: 2.
and if I create an entity
User {ID: 5, Name: "some user" }
with ID 5 assigned, gorm creates the entity. So, when the turn for ID 5 with auto-sequence comes in, pkey violation error occurs.
The expected result would be , that GORM would see ID 5 is already used by another record and use continue from ID 6.
Explain your user case and expected results
When a record is inserted with an assigned ID using db.Create(), that sequence ID is not committed. Example: Given the sequence ID for user table is at ID: 2. and if I create an entity
User {ID: 5, Name: "some user" }
with ID 5 assigned, gorm creates the entity. So, when the turn for ID 5 with auto-sequence comes in, pkey violation error occurs.The expected result would be , that GORM would see ID 5 is already used by another record and use continue from ID 6.