Skip to content

Commit cf573d6

Browse files
feat: auto-include synthetic link dimensions when member is included in a view
When a dimension with links is included in a view (via explicit includes list), its synthetic link dimensions are now automatically included as well. This mirrors how hierarchy level dimensions are auto-included. For includes: '*', synthetic dims are already picked up since they exist as regular dimensions on the source cube. Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
1 parent e90c801 commit cf573d6

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,29 @@ export class CubeSymbols implements TranspilerSymbolResolver, CompilerInterface
712712
.map((path) => path.split('.')[1])
713713
.filter(memberName => !(it.includes as (string | ViewCubeIncludeMember)[]).find((include) => ((typeof include === 'object' ? include.name : include)) === memberName));
714714

715+
// Auto-include synthetic link dimensions for any included dimension that has links
716+
const syntheticLinkMembers: string[] = [];
717+
const membersObj = this.symbols[cubeRef]?.cubeObj()?.dimensions || {};
718+
for (const include of (it.includes as (string | ViewCubeIncludeMember)[])) {
719+
const memberName = typeof include === 'object' ? include.name : include;
720+
const dimDef = membersObj[memberName];
721+
if (dimDef && dimDef.links && Array.isArray(dimDef.links)) {
722+
for (const link of dimDef.links) {
723+
if (link.name) {
724+
const syntheticName = `${memberName}___link_${link.name}_url`;
725+
if (membersObj[syntheticName]) {
726+
syntheticLinkMembers.push(syntheticName);
727+
}
728+
}
729+
}
730+
}
731+
}
732+
715733
return {
716734
...it,
717-
includes: (it.includes as (string | ViewCubeIncludeMember)[]).concat(currentCubeAutoIncludeMembers),
735+
includes: (it.includes as (string | ViewCubeIncludeMember)[])
736+
.concat(currentCubeAutoIncludeMembers)
737+
.concat(syntheticLinkMembers.filter(m => !(it.includes as (string | ViewCubeIncludeMember)[]).find((inc) => ((typeof inc === 'object' ? inc.name : inc)) === m))),
718738
};
719739
}) : includedCubes;
720740

0 commit comments

Comments
 (0)