File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
packages/cubejs-schema-compiler/src/adapter Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -488,6 +488,10 @@ export class BaseQuery {
488488 cnt ++ ;
489489 }
490490
491+ if ( cnt >= 10000 ) {
492+ throw new UserError ( 'Can not construct joins for the query, potential loop detected' ) ;
493+ }
494+
491495 this . collectedJoinHints = R . uniq ( constructJH ( ) ) ;
492496 }
493497 return this . collectedJoinHints ;
@@ -2473,13 +2477,10 @@ export class BaseQuery {
24732477 // In a join between Cube A and Cube B, sql() may reference members from other cubes.
24742478 // These referenced cubes must be added as join hints before Cube B to ensure correct SQL generation.
24752479 const targetCube = s . targetCubeName ( ) ;
2476- const { joinHints } = this . safeEvaluateSymbolContext ( ) ;
2477- let targetIdx = joinHints . findIndex ( e => e === targetCube ) ;
2478- while ( targetIdx > - 1 ) {
2479- joinHints . splice ( targetIdx , 1 ) ;
2480- targetIdx = joinHints . findIndex ( e => e === targetCube ) ;
2481- }
2480+ let { joinHints } = this . safeEvaluateSymbolContext ( ) ;
2481+ joinHints = joinHints . filter ( e => e !== targetCube ) ;
24822482 joinHints . push ( targetCube ) ;
2483+ this . safeEvaluateSymbolContext ( ) . joinHints = joinHints ;
24832484
24842485 // Special processing is required when one cube extends another, because in this case
24852486 // cube names collected during joins evaluation might belong to ancestors which are out of scope of
You can’t perform that action at this time.
0 commit comments