You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling having() on a Builder with a Closure as a parameter, without previously calling having() with a column, throws an error because addNestedHavingQuery() does count($this->havings) which expects $this->havings to be countable (and it's null).
TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given
Steps To Reproduce
see description
The text was updated successfully, but these errors were encountered:
We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here?
Doing what you asked and writing the test to zoom in on the issue caused me to figure out the underlying problem.
I was calling having() with a \Closure but I was not calling any other having()s within that closure.
So, when the havingNested() method stepped into addNestedHavingQuery(), no $query->havings had been set.
That threw the TypeError.
I've expanded the condition determining to call or not call the inner having('column') to outside of the main having(\Closure), so when no having('column') is called, neither is the having(\Closure)
Laravel Version
10
PHP Version
8.3
Database Driver & Version
No response
Description
When calling
having()
on aBuilder
with a Closure as a parameter, without previously callinghaving()
with a column, throws an error becauseaddNestedHavingQuery()
doescount($this->havings)
which expects$this->havings
to be countable (and it'snull
).Steps To Reproduce
see description
The text was updated successfully, but these errors were encountered: