Skip to content

Commit

Permalink
fix(engine): pk uuid
Browse files Browse the repository at this point in the history
Signed-off-by: Yvonnick Esnault <[email protected]>
  • Loading branch information
yesnault committed Jan 19, 2024
1 parent 70a0406 commit 3333d88
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions engine/gorpmapper/encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,16 @@ func (m *Mapper) getEncryptedSliceData(ctx context.Context, db gorp.SqlExecutor,

// Find the right target against the primary key
primaryKeyReference := reflectFindValueByTag(targetSlice.Interface(), "db", key)
// Check the primary key known the from target slice and from the database
var equals bool
if reflect.DeepEqual(primaryKeyReference, newPk) {
equals = true
// here, the pk could be a []uint8. If it's the case, string values are compared
} else if primaryKeyReference == fmt.Sprintf("%s", newPk) {
equals = true
}

// Check the primary key known the from target slice and from the database
if equals {
targetSliceFound = true
// Decrypt all the contents
for idx := range mapping.EncryptedFields {
Expand All @@ -327,7 +335,7 @@ func (m *Mapper) getEncryptedSliceData(ctx context.Context, db gorp.SqlExecutor,
}
}
if !targetSliceFound {
return sdk.WithStack(fmt.Errorf("unmatched element with pk %T %v (%v)", newPk, newPk, pks))
return sdk.WithStack(fmt.Errorf("unmatched element with pk type:%T - value:%v - pks:%v", newPk, newPk, pks))
}
}

Expand Down

0 comments on commit 3333d88

Please sign in to comment.