Skip to content

fix: whereDate and whereTime crash when $column is an Expression#60314

Merged
taylorotwell merged 1 commit into
laravel:13.xfrom
ahawlitschek:fix/where-date-expression-argument
May 29, 2026
Merged

fix: whereDate and whereTime crash when $column is an Expression#60314
taylorotwell merged 1 commit into
laravel:13.xfrom
ahawlitschek:fix/where-date-expression-argument

Conversation

@ahawlitschek
Copy link
Copy Markdown
Contributor

As discussed in #60305 a new version without breaking the Stringable case.

The ->whereDate and ->whereTime functions are typed to accept Expression or string as first parameter ($column). Since Laravel 12, both underlying functions in PostgresGrammar checks whether the $column is a JSON selector using the isJsonSelector($value) function defined in the base grammar. This function uses str_contains and causes a runtime exception if it receives something other than string. Currently, the function is called with the origin value of the $column parameter which in some cases may be Expression.

This changes the parameter from the isJsonSelector to the wrapped column instead of the original one. It also adds tests which check, that using Expression or Stringable in whereDate and whereTime produces proper SQL.

The `->whereDate` and `->whereTime` functions are typed to accept `Expression` or string as first parameter (`$column`). Since Laravel 12, both underlying functions in `PostgresGrammar` checks whether the `$column` is a JSON selector using the `isJsonSelector($value)` function defined in the base grammar. This function uses `str_contains` and causes a runtime exception if it receives something other than string. Currently, the function is called with the origin value of the `$column` parameter which in some cases may be `Expression`.

 This changes the parameter from the `isJsonSelector` to the wrapped column instead of the original one. It also adds tests which check, that using `Expression` or `Stringable` in `whereDate` and `whereTime` produces proper SQL.
@taylorotwell taylorotwell merged commit 4d83904 into laravel:13.x May 29, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants