Skip to content

Commit

Permalink
- patched last inserted ID
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed Dec 3, 2024
1 parent dbc35e4 commit fc52466
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions io/insert/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,25 @@ func (s *session) flush(ctx context.Context, values []interface{}, identities []
return 0, 0, err
}

id, err := result.LastInsertId()
if err != nil {
return 0, 0, err
}

for _, updater := range s.recordUpdaters {
lastInsertedID, err := updater.afterFlush(ctx, values, identities, rowsAffected, id)
var id int64
if s.Dialect.CanLastInsertID {
id, err = result.LastInsertId()
if err != nil {
return 0, 0, err
}
}
if id > 0 {
for _, updater := range s.recordUpdaters {
lastInsertedID, err := updater.afterFlush(ctx, values, identities, rowsAffected, id)
if err != nil {
return 0, 0, err
}

if lastInsertedID > 0 {
id = lastInsertedID
if lastInsertedID > 0 {
id = lastInsertedID
}
}
}

return rowsAffected, id, nil
}

Expand Down

0 comments on commit fc52466

Please sign in to comment.