@@ -461,10 +461,6 @@ public function insert(string $collection, array $document, array $options = [])
461461 $ docObj = new stdClass ();
462462
463463 foreach ($ document as $ key => $ value ) {
464- if (\is_null ($ value )) {
465- continue ;
466- }
467-
468464 $ docObj ->{$ key } = $ value ;
469465 }
470466
@@ -486,10 +482,6 @@ public function insertMany(string $collection, array $documents, array $options
486482 $ docObj = new stdClass ();
487483
488484 foreach ($ document as $ key => $ value ) {
489- if (\is_null ($ value )) {
490- continue ;
491- }
492-
493485 $ docObj ->{$ key } = $ value ;
494486 }
495487
@@ -540,22 +532,14 @@ public function lastDocument(string $collection): array
540532 */
541533 public function update (string $ collection , array $ where = [], array $ updates = [], array $ options = [], bool $ multi = false ): self
542534 {
543- $ cleanUpdates = [];
544-
545- foreach ($ updates as $ k => $ v ) {
546- if (\is_null ($ v )) {
547- continue ;
548- }
549- $ cleanUpdates [$ k ] = $ v ;
550- }
551-
535+
552536 $ this ->query (
553537 array_merge ([
554538 self ::COMMAND_UPDATE => $ collection ,
555539 'updates ' => [
556540 [
557541 'q ' => $ this ->toObject ($ where ),
558- 'u ' => $ this ->toObject ($ cleanUpdates ),
542+ 'u ' => $ this ->toObject ($ updates ),
559543 'multi ' => $ multi ,
560544 'upsert ' => false
561545 ]
@@ -582,16 +566,9 @@ public function upsert(string $collection, array $operations, array $options = [
582566 $ updates = [];
583567
584568 foreach ($ operations as $ op ) {
585- $ cleanUpdate = [];
586- foreach ($ op ['update ' ] as $ k => $ v ) {
587- if (!is_null ($ v )) {
588- $ cleanUpdate [$ k ] = $ v ;
589- }
590- }
591-
592569 $ updateOperation = [
593570 'q ' => $ op ['filter ' ],
594- 'u ' => $ this ->toObject ($ cleanUpdate ),
571+ 'u ' => $ this ->toObject ($ op [ ' update ' ] ),
595572 'upsert ' => true ,
596573 'multi ' => isset ($ op ['multi ' ]) ? $ op ['multi ' ] : false ,
597574 ];
@@ -897,12 +874,7 @@ private function cleanFilters($filters): array
897874
898875 if (in_array ($ k , ['$and ' , '$or ' , '$nor ' ]) && is_array ($ v )) {
899876 $ values = [];
900-
901877 foreach ($ v as $ item ) {
902- if (is_null ($ item )) {
903- continue ;
904- }
905-
906878 $ values [] = is_array ($ item ) ? $ this ->toObject ($ item ) : $ item ;
907879 }
908880
0 commit comments