@@ -146,6 +146,27 @@ interface CrossObjectPlan {
146146 crossDims : CrossObjectPlanDim [ ] ;
147147}
148148
149+ /**
150+ * [#29304] The engine's refusal of a VIRTUAL (`formula`) attribute on the
151+ * cross-object path, judged by the service's copy
152+ * (`dataset-date-bucket-door.ts` `assertDatasetGroupTargetsStored`) on the
153+ * keys that path's FK-resolve aggregate hands the related object
154+ * (`resolveFkAttr`: `groupBy: ['id', attr]`). The engine refuses that
155+ * aggregate, but only once a base row carries a key to resolve: an empty base
156+ * served the dimension, and the echo, which runs nothing, rendered a `LEFT
157+ * JOIN` grouping by a column no table stores. Called by both, after the base
158+ * keys are judged, so the query and its echo give one answer on any data. A
159+ * host that wired no field types is not judged.
160+ */
161+ function assertCrossObjectAttrsStored ( plan : CrossObjectPlan | null | undefined , ctx : StrategyContext ) : void {
162+ const declared = ( ctx as DatasetScopedStrategyContext ) . declaredFieldType ;
163+ if ( ! plan || typeof declared !== 'function' ) return ;
164+ for ( const cd of plan . crossDims ) {
165+ if ( cd . attr === 'id' ) continue ;
166+ assertDatasetGroupTargetsStored ( cd . refObject , [ 'id' , cd . attr ] , ( field ) => declared . call ( ctx , cd . refObject , field ) ) ;
167+ }
168+ }
169+
149170/**
150171 * Why the echo of a date bucket refuses: the in-memory zone, or no driver
151172 * expression for the bucket (with the dialect the host names, `'unknown'` when
@@ -808,6 +829,9 @@ export class ObjectQLStrategy implements AnalyticsStrategy {
808829 // column no table stores.
809830 assertDatasetGroupTargetsStored ( tableName , echoGroupBy , ( field ) => declaredType ?. call ( ctx , tableName , field ) ) ;
810831 assertDatasetDateBucketsTemporal ( tableName , echoGroupBy , ( field ) => declaredType ?. call ( ctx , tableName , field ) ) ;
832+ // [#29304] …then a cross-object dimension over a virtual attribute, as
833+ // `executeCrossObject` judges it after its base aggregate.
834+ assertCrossObjectAttrsStored ( plan , ctx ) ;
811835 const joinClauses : string [ ] = [ ] ;
812836 // [#21441] The bucket expression the driver itself groups by for its
813837 // dialect, read from the `dateBucketSql` hook: `strftime('%Y-%m', …)` on
@@ -1534,6 +1558,10 @@ export class ObjectQLStrategy implements AnalyticsStrategy {
15341558 context : ctx . context ,
15351559 } ) ;
15361560
1561+ // [#29304] A cross-object dimension over a virtual attribute, whether or
1562+ // not a base row carries a key to resolve. See {@link assertCrossObjectAttrsStored}.
1563+ assertCrossObjectAttrsStored ( plan , ctx ) ;
1564+
15371565 // Resolve each cross-object dim's FK → attribute, SCOPED to the referenced
15381566 // object: a related record the caller cannot read never yields its
15391567 // attribute, so it buckets as RESTRICTED (no leak; ADR-0021 D-C / #3602).
0 commit comments