{"record":{"id":"42175f4dbbf39fdb","repo":"hasura/graphql-engine","slug":"the-comparable-relationship-relationship-name-42175f","errorCode":null,"errorMessage":"the comparable relationship '{relationship_name}' for the operand type '{operand_type}' targets a command. This is not supported","messagePattern":"the comparable relationship '(.+?)' for the operand type '(.+?)' targets a command\\. This is not supported","errorType":"validation","errorClass":"AggregateBooleanExpressionError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs","lineNumber":303,"sourceCode":"        boolean_expression_operand_type: QualifiedTypeName,\n    },\n\n    #[error(\n        \"the relationship '{relationship_name}' is defined more than once in the comparable relationships\"\n    )]\n    DuplicateComparableRelationshipsFound {\n        relationship_name: open_dds::relationships::RelationshipName,\n    },\n\n    #[error(\n        \"the comparable relationship '{relationship_name}' was not found for the operand type '{operand_type}'\"\n    )]\n    ComparableRelationshipNotFound {\n        operand_type: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n    },\n\n    #[error(\n        \"the comparable relationship '{relationship_name}' for the operand type '{operand_type}' targets a command. This is not supported\"\n    )]\n    ComparableRelationshipCommandTargetNotSupported {\n        operand_type: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n    },\n\n    #[error(\n        \"the comparable relationship '{relationship_name}' for the operand type '{operand_type}' is an array relationship. This is not supported\"\n    )]\n    ComparableArrayRelationshipNotSupported {\n        operand_type: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n    },\n\n    #[error(\n        \"the comparable relationship '{relationship_name}' for the operand type '{operand_type}' targets a model than cannot be found: '{target_model_name}'\"\n    )]","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs#L285-L321","documentation":"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.","triggerScenarios":"Declaring a relationship whose target is a command as a comparable relationship in an aggregate boolean expression type's metadata.","commonSituations":"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.","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"],"exampleFix":"# before\nrelationships:\n  - name: topPosts\n    target: { command: { name: TopPosts } }\ncomparableRelationships:\n  - relationshipName: topPosts\n\n# after\ncomparableRelationships:\n  - relationshipName: posts   # relationship targeting a model\n","handlingStrategy":"validation","validationCode":"for r in &comparable_relationships {\n    let target = operand_type.relationships[&r.relationship_name].target();\n    assert!(target.is_model(), \"command-targeting relationship cannot be comparable\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document that comparable relationships must target models","Add a lint rejecting command targets in comparableRelationships"],"tags":["rust","hasura","metadata","command-target","aggregation"],"backgroundTag":"unsupported-relationship-target","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}