Skip to content

Commit

Permalink
chore: qa improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
LaravelFreelancerNL committed Dec 15, 2024
1 parent d02cd37 commit 1129c4f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Query/Concerns/BuildsGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ public function forNestedWhere($aliases = [])
*/
public function havingNested(Closure $callback, $boolean = 'and')
{
$callback($query = $this->forNestedWhere($this->groups));


$callback($query = $this->forNestedWhere($this->groups ?? []));

return $this->addNestedHavingQuery($query, $boolean);
}
Expand All @@ -176,7 +174,7 @@ public function havingNested(Closure $callback, $boolean = 'and')
*/
public function addNestedHavingQuery($query, $boolean = 'and')
{
if (count($query->havings)) {
if (count($query->havings ?? [])) {
$type = 'Nested';

$this->havings[] = compact('type', 'query', 'boolean');
Expand Down
4 changes: 4 additions & 0 deletions src/Query/Concerns/CompilesColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ protected function mergeJoinResults(IlluminateQueryBuilder $query, $returnDocs =
{
assert($query instanceof Builder);

if (!is_array($query->joins)) {
return $returnDocs;
}

foreach ($query->joins as $join) {
$tableAlias = $query->getTableAlias($join->table);

Expand Down
6 changes: 6 additions & 0 deletions src/Query/Concerns/CompilesUnions.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ trait CompilesUnions
*/
protected function compileUnions(IlluminateBuilder $query, $firstQuery = '')
{
if (!is_array($query->unions)) {
return '';
}

$unionResultsId = 'union' . $query->getQueryId() . 'Results';
$unionDocId = 'union' . $query->getQueryId() . 'Result';

$query->registerTableAlias($unionResultsId, $unionDocId);

$firstQuery = $this->wrapSubquery($firstQuery);

$unions = '';

foreach ($query->unions as $union) {
$prefix = ($unions !== '') ? $unions : $firstQuery;
$unions = $this->compileUnion($union, $prefix);
Expand Down

0 comments on commit 1129c4f

Please sign in to comment.