diff --git a/src/Converter.php b/src/Converter.php index 915c801..8e346f1 100644 --- a/src/Converter.php +++ b/src/Converter.php @@ -21,8 +21,6 @@ public static function convertJsonPatchToMongoUpdate(array $diff, array $values) continue; } - - switch ($op['op']) { case 'add': if (static::isPathArray($op['path'])) { @@ -79,6 +77,14 @@ public static function convertJsonPatchToMongoUpdate(array $diff, array $values) } } + foreach (array_keys($arrayFullReset) as $arrayResetPath) { + foreach (array_keys($update['$push']) as $pushPath) { + if (0 === strpos($pushPath, $arrayResetPath)) { + unset($update['$push'][$pushPath]); + } + } + } + foreach (array_keys($arrayFullReset) as $arrayResetPath) { foreach (array_keys($update['$unset']) as $setPath) { if (0 === strpos($setPath, $arrayResetPath)) {