@@ -124,9 +124,10 @@ public static function provideQueryBuilderToMql(): iterable
124
124
];
125
125
126
126
// Nested array are not flattened like in the Eloquent builder. MongoDB can compare objects.
127
+ // When id is used as data field name, it's not converted to _id
127
128
$ array = [['issue ' => 45582 ], ['id ' => 2 ], [3 ]];
128
129
yield 'whereIn nested array ' => [
129
- ['find ' => [['id ' => ['$in ' => $ array ]], []]],
130
+ ['find ' => [['_id ' => ['$in ' => $ array ]], []]],
130
131
fn (Builder $ builder ) => $ builder ->whereIn ('id ' , $ array ),
131
132
];
132
133
@@ -170,7 +171,7 @@ public static function provideQueryBuilderToMql(): iterable
170
171
171
172
/** @see DatabaseQueryBuilderTest::testEmptyWhereIns */
172
173
yield 'whereIn empty array ' => [
173
- ['find ' => [['id ' => ['$in ' => []]], []]],
174
+ ['find ' => [['_id ' => ['$in ' => []]], []]],
174
175
fn (Builder $ builder ) => $ builder ->whereIn ('id ' , []),
175
176
];
176
177
@@ -553,12 +554,12 @@ function (Builder $builder) {
553
554
554
555
/** @see DatabaseQueryBuilderTest::testWhereBetweens() */
555
556
yield 'whereBetween array of numbers ' => [
556
- ['find ' => [['id ' => ['$gte ' => 1 , '$lte ' => 2 ]], []]],
557
+ ['find ' => [['_id ' => ['$gte ' => 1 , '$lte ' => 2 ]], []]],
557
558
fn (Builder $ builder ) => $ builder ->whereBetween ('id ' , [1 , 2 ]),
558
559
];
559
560
560
561
yield 'whereBetween nested array of numbers ' => [
561
- ['find ' => [['id ' => ['$gte ' => [1 ], '$lte ' => [2 , 3 ]]], []]],
562
+ ['find ' => [['_id ' => ['$gte ' => [1 ], '$lte ' => [2 , 3 ]]], []]],
562
563
fn (Builder $ builder ) => $ builder ->whereBetween ('id ' , [[1 ], [2 , 3 ]]),
563
564
];
564
565
@@ -579,7 +580,7 @@ function (Builder $builder) {
579
580
];
580
581
581
582
yield 'whereBetween collection ' => [
582
- ['find ' => [['id ' => ['$gte ' => 1 , '$lte ' => 2 ]], []]],
583
+ ['find ' => [['_id ' => ['$gte ' => 1 , '$lte ' => 2 ]], []]],
583
584
fn (Builder $ builder ) => $ builder ->whereBetween ('id ' , collect ([1 , 2 ])),
584
585
];
585
586
0 commit comments