From 8d61d69592b953328c63d4fffd8e175c7422e49c Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 20 Feb 2018 12:23:02 +0200 Subject: [PATCH] Fix adding an array (do not cast int keys into strings) --- src/Converter.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Converter.php b/src/Converter.php index 918d15d..f29f04b 100644 --- a/src/Converter.php +++ b/src/Converter.php @@ -25,6 +25,8 @@ public static function convertJsonPatchToMongoUpdate(array $diff) } $update['$push'][self::pathToDotWithoutLastPart($op['path'])]['$each'][] = $op['value']; + } else if (is_array($op['value']) && array_key_exists(0, $op['value'])) { + $update['$set'][self::pathToDot($op['path'])] = $op['value']; } else if (is_array($op['value'])) { foreach ($op['value'] as $key => $value) { $update['$set'][self::pathToDot($op['path']) . '.' . $key] = $value;