filamentphp/filament · error · LogicException

Relationship type [{get_class($relationship)}] is not suppor

Error message

Relationship type [{get_class($relationship)}] is not supported for aggregate queries.

What it means

Error "Relationship type [{get_class($relationship)}] is not supported for aggregate queries." thrown in filamentphp/filament.

Source

Thrown at packages/query-builder/src/Constraints/NumberConstraint/Operators/Concerns/CanAggregateRelationships.php:108

            return $query->whereRaw("({$subQuery->toSql()}) {$operator} ?", [...$subQuery->getBindings(), $value]);
        }

        if ($relationship instanceof HasOneOrMany) {
            $foreignKeyName = $relationship->getQualifiedForeignKeyName();
            $parentKeyName = $relationship->getQualifiedParentKeyName();

            $subQuery = $relatedModel->query()
                ->selectRaw("cast({$aggregate}({$attributeForQuery}) as {$castType})")
                ->whereColumn($foreignKeyName, $parentKeyName);

            if ($modifyRelationshipQueryUsing) {
                $subQuery = $this->evaluate($modifyRelationshipQueryUsing, ['query' => $subQuery]) ?? $subQuery;
            }

            return $query->whereRaw("({$subQuery->toSql()}) {$operator} ?", [...$subQuery->getBindings(), $value]);
        }

        throw new LogicException('Relationship type [' . get_class($relationship) . '] is not supported for aggregate queries.');
    }

    protected function getAggregateSelect(): Select
    {
        return Select::make(static::getAggregateSelectName())
            ->label(__('filament-query-builder::query-builder.operators.number.form.aggregate.label'))
            ->options([
                static::getAggregateSumKey() => __('filament-query-builder::query-builder.operators.number.aggregates.sum.label'),
                static::getAggregateAverageKey() => __('filament-query-builder::query-builder.operators.number.aggregates.average.label'),
                static::getAggregateMaxKey() => __('filament-query-builder::query-builder.operators.number.aggregates.max.label'),
                static::getAggregateMinKey() => __('filament-query-builder::query-builder.operators.number.aggregates.min.label'),
            ])
            ->visible($this->getConstraint()->queriesRelationships());
    }

    protected function getAggregate(): ?string
    {
        $aggregate = $this->getSettings()[static::getAggregateSelectName()] ?? null;

View on GitHub (pinned to 53483fa934)

When it happens

Trigger: Thrown at packages/query-builder/src/Constraints/NumberConstraint/Operators/Concerns/CanAggregateRelationships.php:108 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of filamentphp/filament@53483fa934 (2026-08-17). Data as JSON: /api/errors/0d8a1cc3733253fa. Report an issue: GitHub.