Skip to content

Commit

Permalink
Fixed aggregate relational queries like count()
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Feb 7, 2024
1 parent 4c42d8c commit 77d059a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/fields/BaseRelationField.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,10 +702,8 @@ public function normalizeValue(mixed $value, ?ElementInterface $element): mixed
if (
$this->sortable &&
!$this->maintainHierarchy &&
(
!$query->orderBy ||
(count($query->orderBy) === 1) && ($query->orderBy[0] ?? null) instanceof OrderByPlaceholderExpression
)
count($query->orderBy ?? []) === 1 &&
($query->orderBy[0] ?? null) instanceof OrderByPlaceholderExpression
) {
$q->orderBy(["$relationsAlias.sortOrder" => SORT_ASC]);
}
Expand Down

0 comments on commit 77d059a

Please sign in to comment.