From 9ec6cfd6add6fdd34e090fb2f5950c79d5eb3c69 Mon Sep 17 00:00:00 2001 From: Kassian Sun Date: Wed, 22 Jan 2025 14:30:59 +0800 Subject: [PATCH] refactor: reorganize transformInteriorValue This code was checking a constantly true condition value !== CannotTransform, that's why the code was not properly handling nested structure properly, The code introduced by #8446 fixed this logic, by introducing another duplicated piece of code. This commit simplifies the logic here to reflect the original purpose. --- src/Adapters/Storage/Mongo/MongoTransform.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Adapters/Storage/Mongo/MongoTransform.js b/src/Adapters/Storage/Mongo/MongoTransform.js index 336d9affc9..f35ff7ed74 100644 --- a/src/Adapters/Storage/Mongo/MongoTransform.js +++ b/src/Adapters/Storage/Mongo/MongoTransform.js @@ -187,17 +187,11 @@ const transformInteriorValue = restValue => { } // Handle atomic values var value = transformInteriorAtom(restValue); - if (value !== CannotTransform) { - if (value && typeof value === 'object') { - if (value instanceof Date) { - return value; - } - if (value instanceof Array) { - value = value.map(transformInteriorValue); - } else { - value = mapValues(value, transformInteriorValue); - } - } + if (value === CannotTransform) { + return value; + } + + if (value instanceof Date) { return value; }