Skip to content

Commit 0317ba4

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

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Query/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,8 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
984984
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)));
985985
}
986986

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)));
987+
if (is_float($column) || is_bool($column) || is_null($column)) {
988+
throw new InvalidArgumentException(sprintf('First argument of %s must be a field path as "string". Got "%s"', __METHOD__, get_debug_type($column)));
989989
}
990990

991991
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)