Skip to content

Commit d8f6e2a

Browse files
committed
Revert column type detection, as the number of arguments is unreliable
1 parent 5a7e108 commit d8f6e2a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Query/Builder.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@
4545
use function implode;
4646
use function in_array;
4747
use function is_array;
48+
use function is_bool;
4849
use function is_callable;
50+
use function is_float;
4951
use function is_int;
52+
use function is_null;
5053
use function is_string;
5154
use function md5;
5255
use function preg_match;
@@ -984,8 +987,8 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
984987
throw new ArgumentCountError(sprintf('Too few arguments to function %s(%s), 1 passed and at least 2 expected when the 1st is not an array or a callable', __METHOD__, var_export($column, true)));
985988
}
986989

987-
if (! is_int($column) && ! is_string($column)) {
988-
throw new InvalidArgumentException(sprintf('First argument of %s must be a column name as "string". Got "%s"', __METHOD__, get_debug_type($column)));
990+
if (is_float($column) || is_bool($column) || is_null($column)) {
991+
throw new InvalidArgumentException(sprintf('First argument of %s must be a field path as "string". Got "%s"', __METHOD__, get_debug_type($column)));
989992
}
990993

991994
return parent::where(...$params);

tests/Query/BuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ public static function provideExceptions(): iterable
12221222

12231223
yield 'where invalid column type' => [
12241224
InvalidArgumentException::class,
1225-
'First argument of MongoDB\Laravel\Query\Builder::where must be a column name as "string". Got "float"',
1225+
'First argument of MongoDB\Laravel\Query\Builder::where must be a field path as "string". Got "float"',
12261226
fn (Builder $builder) => $builder->where(2.3, '>', 1),
12271227
];
12281228
}

0 commit comments

Comments
 (0)