Skip to content

Commit

Permalink
feat(insert): get last insert id only with pk support auto increment
Browse files Browse the repository at this point in the history
  • Loading branch information
j2gg0s committed Jan 24, 2022
1 parent 838ed6b commit 79e7c79
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion query_insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ func (q *InsertQuery) afterInsertHook(ctx context.Context) error {
}

func (q *InsertQuery) tryLastInsertID(res sql.Result, dest []interface{}) error {
if q.db.features.Has(feature.Returning) || q.table == nil || len(q.table.PKs) != 1 {
if q.db.features.Has(feature.Returning) || q.table == nil || len(q.table.PKs) != 1 || !q.table.PKs[0].AutoIncrement {
return nil
}

Expand Down

0 comments on commit 79e7c79

Please sign in to comment.