Skip to content

Commit

Permalink
refactor: reorganize transformInteriorValue
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kassiansun committed Jan 22, 2025
1 parent 42f785e commit 9ec6cfd
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/Adapters/Storage/Mongo/MongoTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 9ec6cfd

Please sign in to comment.