@@ -262,6 +262,7 @@ public function aggregate(array $pipeline, array $options = [])
262262 */
263263 public function bulkWrite (array $ operations , array $ options = [])
264264 {
265+ $ options = $ this ->inheritBuilderEncoder ($ options );
265266 $ options = $ this ->inheritWriteOptions ($ options );
266267 $ options = $ this ->inheritCodec ($ options );
267268
@@ -286,6 +287,7 @@ public function bulkWrite(array $operations, array $options = [])
286287 */
287288 public function count (array |object $ filter = [], array $ options = [])
288289 {
290+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
289291 $ options = $ this ->inheritReadOptions ($ options );
290292
291293 $ operation = new Count ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
@@ -307,6 +309,7 @@ public function count(array|object $filter = [], array $options = [])
307309 */
308310 public function countDocuments (array |object $ filter = [], array $ options = [])
309311 {
312+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
310313 $ options = $ this ->inheritReadOptions ($ options );
311314
312315 $ operation = new CountDocuments ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
@@ -444,6 +447,7 @@ public function createSearchIndexes(array $indexes, array $options = []): array
444447 */
445448 public function deleteMany (array |object $ filter , array $ options = [])
446449 {
450+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
447451 $ options = $ this ->inheritWriteOptions ($ options );
448452
449453 $ operation = new DeleteMany ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
@@ -465,6 +469,7 @@ public function deleteMany(array|object $filter, array $options = [])
465469 */
466470 public function deleteOne (array |object $ filter , array $ options = [])
467471 {
472+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
468473 $ options = $ this ->inheritWriteOptions ($ options );
469474
470475 $ operation = new DeleteOne ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
@@ -487,6 +492,7 @@ public function deleteOne(array|object $filter, array $options = [])
487492 */
488493 public function distinct (string $ fieldName , array |object $ filter = [], array $ options = [])
489494 {
495+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
490496 $ options = $ this ->inheritReadOptions ($ options );
491497 $ options = $ this ->inheritTypeMap ($ options );
492498
@@ -645,6 +651,7 @@ public function explain(Explainable $explainable, array $options = [])
645651 */
646652 public function find (array |object $ filter = [], array $ options = [])
647653 {
654+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
648655 $ options = $ this ->inheritReadOptions ($ options );
649656 $ options = $ this ->inheritCodecOrTypeMap ($ options );
650657
@@ -667,6 +674,7 @@ public function find(array|object $filter = [], array $options = [])
667674 */
668675 public function findOne (array |object $ filter = [], array $ options = [])
669676 {
677+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
670678 $ options = $ this ->inheritReadOptions ($ options );
671679 $ options = $ this ->inheritCodecOrTypeMap ($ options );
672680
@@ -692,6 +700,7 @@ public function findOne(array|object $filter = [], array $options = [])
692700 */
693701 public function findOneAndDelete (array |object $ filter , array $ options = [])
694702 {
703+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
695704 $ options = $ this ->inheritWriteOptions ($ options );
696705 $ options = $ this ->inheritCodecOrTypeMap ($ options );
697706
@@ -722,6 +731,7 @@ public function findOneAndDelete(array|object $filter, array $options = [])
722731 */
723732 public function findOneAndReplace (array |object $ filter , array |object $ replacement , array $ options = [])
724733 {
734+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
725735 $ options = $ this ->inheritWriteOptions ($ options );
726736 $ options = $ this ->inheritCodecOrTypeMap ($ options );
727737
@@ -752,6 +762,7 @@ public function findOneAndReplace(array|object $filter, array|object $replacemen
752762 */
753763 public function findOneAndUpdate (array |object $ filter , array |object $ update , array $ options = [])
754764 {
765+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
755766 $ options = $ this ->inheritWriteOptions ($ options );
756767 $ options = $ this ->inheritCodecOrTypeMap ($ options );
757768
@@ -1000,6 +1011,7 @@ public function rename(string $toCollectionName, ?string $toDatabaseName = null,
10001011 */
10011012 public function replaceOne (array |object $ filter , array |object $ replacement , array $ options = [])
10021013 {
1014+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
10031015 $ options = $ this ->inheritWriteOptions ($ options );
10041016 $ options = $ this ->inheritCodec ($ options );
10051017
@@ -1023,6 +1035,8 @@ public function replaceOne(array|object $filter, array|object $replacement, arra
10231035 */
10241036 public function updateMany (array |object $ filter , array |object $ update , array $ options = [])
10251037 {
1038+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
1039+ $ update = $ this ->builderEncoder ->encodeIfSupported ($ update );
10261040 $ options = $ this ->inheritWriteOptions ($ options );
10271041
10281042 $ operation = new UpdateMany ($ this ->databaseName , $ this ->collectionName , $ filter , $ update , $ options );
@@ -1045,6 +1059,8 @@ public function updateMany(array|object $filter, array|object $update, array $op
10451059 */
10461060 public function updateOne (array |object $ filter , array |object $ update , array $ options = [])
10471061 {
1062+ $ filter = $ this ->builderEncoder ->encodeIfSupported ($ filter );
1063+ $ update = $ this ->builderEncoder ->encodeIfSupported ($ update );
10481064 $ options = $ this ->inheritWriteOptions ($ options );
10491065
10501066 $ operation = new UpdateOne ($ this ->databaseName , $ this ->collectionName , $ filter , $ update , $ options );
@@ -1112,6 +1128,11 @@ public function withOptions(array $options = [])
11121128 return new Collection ($ this ->manager , $ this ->databaseName , $ this ->collectionName , $ options );
11131129 }
11141130
1131+ private function inheritBuilderEncoder (array $ options ): array
1132+ {
1133+ return ['builderEncoder ' => $ this ->builderEncoder ] + $ options ;
1134+ }
1135+
11151136 private function inheritCodec (array $ options ): array
11161137 {
11171138 // If the options contain a type map, don't inherit anything
0 commit comments