Skip to content

Commit 15b951e

Browse files
committed
fix: serialize having children without treating them as filters
Having must nest Query objects in toArray so parse works, but it must not be a LOGICAL_TYPE. Recursing having children through the collection Filter rejects aggregate aliases such as total.
1 parent fd10d09 commit 15b951e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/Database/Query.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Query extends BaseQuery
3232
*
3333
* @var list<Method>
3434
*/
35-
public const array LOGICAL_TYPES = [Method::And, Method::Or, Method::ElemMatch, Method::Having];
35+
public const array LOGICAL_TYPES = [Method::And, Method::Or, Method::ElemMatch];
3636

3737
public const TYPE_ELEM_MATCH = 'elemMatch';
3838

@@ -215,7 +215,7 @@ public function toArray(): array
215215
$array['attribute'] = $this->attribute;
216216
}
217217

218-
if (\in_array($this->method, self::LOGICAL_TYPES, true)) {
218+
if (\in_array($this->method, self::LOGICAL_TYPES, true) || $this->method === Method::Having) {
219219
foreach ($this->values as $index => $value) {
220220
if (! $value instanceof self) {
221221
throw new QueryException(

0 commit comments

Comments
 (0)