Skip to content

Commit e2f1c50

Browse files
committed
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.
1 parent 42f785e commit e2f1c50

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/Adapters/Storage/Mongo/MongoTransform.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,15 @@ const transformInteriorValue = restValue => {
187187
}
188188
// Handle atomic values
189189
var value = transformInteriorAtom(restValue);
190-
if (value !== CannotTransform) {
191-
if (value && typeof value === 'object') {
192-
if (value instanceof Date) {
193-
return value;
194-
}
195-
if (value instanceof Array) {
196-
value = value.map(transformInteriorValue);
197-
} else {
198-
value = mapValues(value, transformInteriorValue);
199-
}
200-
}
190+
191+
// If cannot transform, return it
192+
// transformInteriorAtom doesn't return CannotTransform, just in case
193+
if (value === CannotTransform) {
194+
return value;
195+
}
196+
197+
// If the value was mutated (thus transformed), return it
198+
if (value !== restValue) {
201199
return value;
202200
}
203201

0 commit comments

Comments
 (0)