Skip to content

Commit

Permalink
Remove $push for full reset arrays.
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Jul 13, 2018
1 parent a0ba651 commit dcf6296
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public static function convertJsonPatchToMongoUpdate(array $diff, array $values)
continue;
}



switch ($op['op']) {
case 'add':
if (static::isPathArray($op['path'])) {
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit dcf6296

Please sign in to comment.