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 ;
@@ -2489,13 +2493,10 @@ export class BaseQuery {
24892493 // In a join between Cube A and Cube B, sql() may reference members from other cubes.
24902494 // These referenced cubes must be added as join hints before Cube B to ensure correct SQL generation.
24912495 const targetCube = s . targetCubeName ( ) ;
2492- const { joinHints } = this . safeEvaluateSymbolContext ( ) ;
2493- let targetIdx = joinHints . findIndex ( e => e === targetCube ) ;
2494- while ( targetIdx > - 1 ) {
2495- joinHints . splice ( targetIdx , 1 ) ;
2496- targetIdx = joinHints . findIndex ( e => e === targetCube ) ;
2497- }
2496+ let { joinHints } = this . safeEvaluateSymbolContext ( ) ;
2497+ joinHints = joinHints . filter ( e => e !== targetCube ) ;
24982498 joinHints . push ( targetCube ) ;
2499+ this . safeEvaluateSymbolContext ( ) . joinHints = joinHints ;
24992500
25002501 // Special processing is required when one cube extends another, because in this case
25012502 // 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