hasura/graphql-engine · error · AggregateBooleanExpressionError
the comparable relationship '{relationship_name}' for the op
Error message
the comparable relationship '{relationship_name}' for the operand type '{operand_type}' targets a command. This is not supported What it means
Comparable relationships used for aggregation must target a model, not a command. If the resolved relationship target is a command, the resolver cannot build nested aggregate boolean expressions over it and throws this error.
Source
Thrown at v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs:303
boolean_expression_operand_type: QualifiedTypeName,
},
#[error(
"the relationship '{relationship_name}' is defined more than once in the comparable relationships"
)]
DuplicateComparableRelationshipsFound {
relationship_name: open_dds::relationships::RelationshipName,
},
#[error(
"the comparable relationship '{relationship_name}' was not found for the operand type '{operand_type}'"
)]
ComparableRelationshipNotFound {
operand_type: Qualified<CustomTypeName>,
relationship_name: RelationshipName,
},
#[error(
"the comparable relationship '{relationship_name}' for the operand type '{operand_type}' targets a command. This is not supported"
)]
ComparableRelationshipCommandTargetNotSupported {
operand_type: Qualified<CustomTypeName>,
relationship_name: RelationshipName,
},
#[error(
"the comparable relationship '{relationship_name}' for the operand type '{operand_type}' is an array relationship. This is not supported"
)]
ComparableArrayRelationshipNotSupported {
operand_type: Qualified<CustomTypeName>,
relationship_name: RelationshipName,
},
#[error(
"the comparable relationship '{relationship_name}' for the operand type '{operand_type}' targets a model than cannot be found: '{target_model_name}'"
)]View on GitHub (pinned to 724551b9ae)
Solutions
- Remove the command-targeting relationship from comparableRelationships
- If aggregation support is needed, create a model-based relationship targeting the same underlying data and use that instead
- Restructure the command as a model if it must support aggregate boolean expressions
Example fix
# before
relationships:
- name: topPosts
target: { command: { name: TopPosts } }
comparableRelationships:
- relationshipName: topPosts
# after
comparableRelationships:
- relationshipName: posts # relationship targeting a model
Defensive patterns
Strategy: validation
Validate before calling
for r in &comparable_relationships {
let target = operand_type.relationships[&r.relationship_name].target();
assert!(target.is_model(), "command-targeting relationship cannot be comparable");
} Prevention
- Document that comparable relationships must target models
- Add a lint rejecting command targets in comparableRelationships
When it happens
Trigger: Declaring a relationship whose target is a command as a comparable relationship in an aggregate boolean expression type's metadata.
Common situations: Using command-based relationships (e.g. relationships backed by a custom query/command) and assuming they support aggregation filters; migrating from model targets to command targets without removing them from comparable relationships.
Related errors
- the type of the comparable field '{field_name}' ({field_type
- the boolean expression type ({boolean_expression_type}) used
- the comparable relationship '{relationship_name}' for the op
- Condition {condition_hash} not found
- could not find a scalar-operanded boolean expression type na
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/42175f4dbbf39fdb.
Report an issue: GitHub.