Skip to content

Commit

Permalink
Revert column type detection, as the number of arguments is unreliable
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Oct 19, 2023
1 parent 5a7e108 commit 0317ba4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,8 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
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)));
}

if (! is_int($column) && ! is_string($column)) {
throw new InvalidArgumentException(sprintf('First argument of %s must be a column name as "string". Got "%s"', __METHOD__, get_debug_type($column)));
if (is_float($column) || is_bool($column) || is_null($column)) {

Check failure on line 987 in src/Query/Builder.php

View workflow job for this annotation

GitHub Actions / phpcs

Function is_float() should not be referenced via a fallback global name, but via a use statement.

Check failure on line 987 in src/Query/Builder.php

View workflow job for this annotation

GitHub Actions / phpcs

Function is_bool() should not be referenced via a fallback global name, but via a use statement.

Check failure on line 987 in src/Query/Builder.php

View workflow job for this annotation

GitHub Actions / phpcs

Function is_null() should not be referenced via a fallback global name, but via a use statement.

Check failure on line 987 in src/Query/Builder.php

View workflow job for this annotation

GitHub Actions / phpcs

The use of function is_null() is forbidden
throw new InvalidArgumentException(sprintf('First argument of %s must be a field path as "string". Got "%s"', __METHOD__, get_debug_type($column)));
}

return parent::where(...$params);
Expand Down
2 changes: 1 addition & 1 deletion tests/Query/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ public static function provideExceptions(): iterable

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

0 comments on commit 0317ba4

Please sign in to comment.