Skip to content

Commit

Permalink
Dont overwrite id with 0
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamNHarvey committed Jul 19, 2023
1 parent f7b2de4 commit 023bedd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions dialect_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@ func genericCreate(c *Connection, model *Model, cols columns.Columns, quoter quo
if err != nil {
return err
}
id, err = res.LastInsertId()
if err == nil {
model.setID(id)
}
if err != nil {
return err
// If the model isn't using auto_increment, the id is already set
if model.UsingAutoIncrement() {
id, err = res.LastInsertId()
if err == nil {
model.setID(id)
}
if err != nil {
return err
}
}
return nil
case "UUID", "string":
Expand Down

0 comments on commit 023bedd

Please sign in to comment.