Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
demoManito committed Mar 16, 2024
1 parent 2aea425 commit fc542ed
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions callbacks/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,32 @@ func Create(config *Config) func(db *gorm.DB) {
insertID += pkField.AutoIncrementIncrement
} else {
// If the primary key is set, the next primary key value is incremented from that primary key
switch field.(type) {
case int, int8, int16, int32, int64:
insertID = field.(int64) + pkField.AutoIncrementIncrement
case uint, uint8, uint16, uint32, uint64:
insertID = field.(int64) + pkField.AutoIncrementIncrement
var pk int64
switch fieldPK := field.(type) {
case int:
pk = int64(fieldPK)
case int8:
pk = int64(fieldPK)
case int16:
pk = int64(fieldPK)
case int32:
pk = int64(fieldPK)
case int64:
pk = fieldPK
case uint:
pk = int64(fieldPK)
case uint8:
pk = int64(fieldPK)
case uint16:
pk = int64(fieldPK)
case uint32:
pk = int64(fieldPK)
case uint64:
pk = int64(fieldPK)
default:
// PASS
pk = insertID
}
insertID = pk + pkField.AutoIncrementIncrement
}
}
}
Expand Down

0 comments on commit fc542ed

Please sign in to comment.