Skip to content

Commit 8012341

Browse files
authored
fix(schema-compiler): Fix joins getter in cube symbols (#9904)
1 parent 746d336 commit 8012341

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

packages/cubejs-schema-compiler/src/compiler/CubeSymbols.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,27 @@ export class CubeSymbols {
331331

332332
get joins() {
333333
if (!joins) {
334-
const parentJoins = cubeDefinition.extends ? super.joins : [];
335-
joins = [...parentJoins, ...(cubeDefinition.joins || [])];
334+
// In dynamic models we still can hit the cases where joins are returned as map
335+
// instead of array, so we need to convert them here to array.
336+
// TODO: Simplify/Remove this when we drop map joins support totally.
337+
let parentJoins = cubeDefinition.extends ? super.joins : [];
338+
if (!Array.isArray(parentJoins)) {
339+
parentJoins = Object.entries(parentJoins).map(([name, join]: [string, any]) => {
340+
join.name = name;
341+
return join as JoinDefinition;
342+
});
343+
}
344+
345+
let localJoins = cubeDefinition.joins || [];
346+
// TODO: Simplify/Remove this when we drop map joins support totally.
347+
if (!Array.isArray(localJoins)) {
348+
localJoins = Object.entries(localJoins).map(([name, join]: [string, any]) => {
349+
join.name = name;
350+
return join as JoinDefinition;
351+
});
352+
}
353+
354+
joins = [...parentJoins, ...localJoins];
336355
}
337356
return joins;
338357
},

0 commit comments

Comments
 (0)