From e7040363386ab228ff927046cebb284b5c6956a8 Mon Sep 17 00:00:00 2001 From: Yvonnick Esnault Date: Fri, 19 Jan 2024 09:49:27 +0000 Subject: [PATCH] fix(engine): pk uuid Signed-off-by: Yvonnick Esnault --- engine/gorpmapper/encryption.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engine/gorpmapper/encryption.go b/engine/gorpmapper/encryption.go index ad14e60c4b..3d44494fb5 100644 --- a/engine/gorpmapper/encryption.go +++ b/engine/gorpmapper/encryption.go @@ -304,8 +304,10 @@ 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 - if reflect.DeepEqual(primaryKeyReference, newPk) { + // the pk could be a []uint8. If it's the case, string values are compared + if reflect.DeepEqual(primaryKeyReference, newPk) || primaryKeyReference == fmt.Sprintf("%s", newPk) { targetSliceFound = true // Decrypt all the contents for idx := range mapping.EncryptedFields { @@ -327,7 +329,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)) } }