Skip to content

Commit

Permalink
Fix uniqueness check in InsertOrGetFFI to match indexes
Browse files Browse the repository at this point in the history
When guessing the reason for an insert conflict, the query needs to exactly match
the configured database indexes. That means that the "name" and "networkName"
queries need to both include "version" as well, otherwise we risk grabbing a
row that isn't actually a conflict.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
  • Loading branch information
awrichar committed Jun 19, 2023
1 parent 2fbd5b6 commit 197c4d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/database/sqlcommon/ffi_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ func (s *SQLCommon) InsertOrGetFFI(ctx context.Context, ffi *fftypes.FFI) (exist
sq.Eq{"namespace": ffi.Namespace},
sq.Or{
sq.Eq{"id": ffi.ID},
sq.Eq{"name": ffi.Name},
sq.Eq{"network_name": ffi.NetworkName},
sq.Eq{"name": ffi.Name, "version": ffi.Version},
sq.Eq{"network_name": ffi.NetworkName, "version": ffi.Version},
},
})
if queryErr != nil || existing != nil {
Expand Down

0 comments on commit 197c4d4

Please sign in to comment.