Skip to content

Commit

Permalink
Upsert pins if unable to insert due to conflict
Browse files Browse the repository at this point in the history
Signed-off-by: Nicko Guyer <[email protected]>
  • Loading branch information
nguyer authored and EnriqueL8 committed Nov 12, 2024
1 parent 552ad1e commit a7fcea7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/database/sqlcommon/pin_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ func (s *SQLCommon) UpsertPin(ctx context.Context, pin *core.Pin) (err error) {
}

func (s *SQLCommon) attemptPinInsert(ctx context.Context, tx *dbsql.TXWrapper, pin *core.Pin) (err error) {
pin.Sequence, err = s.InsertTx(ctx, pinsTable, tx,
requestConflictEmptyResult := true
pin.Sequence, err = s.InsertTxExt(ctx, pinsTable, tx,
s.setPinInsertValues(sq.Insert(pinsTable).Columns(pinColumns...), pin),
func() {
log.L(ctx).Debugf("Triggering creation event for pin %d", pin.Sequence)
s.callbacks.OrderedCollectionNSEvent(database.CollectionPins, core.ChangeEventTypeCreated, pin.Namespace, pin.Sequence)
},
)
}, requestConflictEmptyResult)
return err
}

Expand Down

0 comments on commit a7fcea7

Please sign in to comment.