Skip to content

Commit e0140e0

Browse files
committed
code polish
1 parent 572f838 commit e0140e0

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ export class CubeSymbols {
441441
const cubeReference = split[split.length - 1];
442442
const cubeName = cubeInclude.alias || cubeReference;
443443

444-
let includes;
444+
let includes: any[];
445445
const fullMemberName = (memberName: string) => (cubeInclude.prefix ? `${cubeName}_${memberName}` : memberName);
446446

447447
if (cubeInclude.includes === '*') {
@@ -582,7 +582,7 @@ export class CubeSymbols {
582582

583583
/**
584584
* This method is mainly used for evaluating RLS conditions and filters.
585-
* It allows referencing security_context (lowecase) in dynamic conditions or filter values.
585+
* It allows referencing security_context (lowercase) in dynamic conditions or filter values.
586586
*
587587
* It currently does not support async calls because inner resolveSymbol and
588588
* resolveSymbolsCall are sync. Async support may be added later with deeper
@@ -591,7 +591,7 @@ export class CubeSymbols {
591591
protected evaluateContextFunction(cube: any, contextFn: any, context: any = {}) {
592592
const cubeEvaluator = this;
593593

594-
const res = cubeEvaluator.resolveSymbolsCall(contextFn, (name: string) => {
594+
return cubeEvaluator.resolveSymbolsCall(contextFn, (name: string) => {
595595
const resolvedSymbol = this.resolveSymbol(cube, name);
596596
if (resolvedSymbol) {
597597
return resolvedSymbol;
@@ -604,8 +604,6 @@ export class CubeSymbols {
604604
securityContext: context.securityContext,
605605
}
606606
});
607-
608-
return res;
609607
}
610608

611609
protected evaluateReferences<T extends ToString | Array<ToString>>(
@@ -740,15 +738,14 @@ export class CubeSymbols {
740738
}
741739

742740
protected depsContextSymbols() {
743-
return Object.assign({
741+
return {
744742
filterParams: this.filtersProxyDep(),
745743
filterGroup: this.filterGroupFunctionDep(),
746744
securityContext: BaseQuery.contextSymbolsProxyFrom({}, (param) => param),
747745
sqlUtils: {
748746
convertTz: (f) => f
749-
750747
},
751-
});
748+
};
752749
}
753750

754751
protected filtersProxyDep() {
@@ -793,7 +790,7 @@ export class CubeSymbols {
793790

794791
if (CONTEXT_SYMBOLS[name]) {
795792
// always resolves if contextSymbols aren't passed for transpile step
796-
const symbol = contextSymbols && contextSymbols[CONTEXT_SYMBOLS[name]] || {};
793+
const symbol = contextSymbols?.[CONTEXT_SYMBOLS[name]] || {};
797794
// eslint-disable-next-line no-underscore-dangle
798795
symbol._objectWithResolvedProperties = true;
799796
return symbol;
@@ -825,12 +822,12 @@ export class CubeSymbols {
825822
const parentIndex = currResolveIndexFn();
826823
cube = this.cubeDependenciesProxy(parentIndex, newCubeName);
827824
return cube;
828-
} else if (this.symbols[cubeName] && this.symbols[cubeName][name] && this.symbols[cubeName][name].type === 'time') {
825+
} else if (this.symbols[cubeName]?.[name] && this.symbols[cubeName][name].type === 'time') {
829826
const parentIndex = currResolveIndexFn();
830827
return this.timeDimDependenciesProxy(parentIndex);
831828
}
832829
}
833-
return cube || (this.symbols[cubeName] && this.symbols[cubeName][name]);
830+
return cube || this.symbols[cubeName]?.[name];
834831
}
835832

836833
protected cubeReferenceProxy(cubeName, joinHints?: any[], refProperty?: any) {
@@ -920,7 +917,7 @@ export class CubeSymbols {
920917
return { interval: `1 ${granName}` };
921918
}
922919

923-
return cube && cube[dimName] && cube[dimName][gr] && cube[dimName][gr][granName];
920+
return cube?.[dimName]?.[gr]?.[granName];
924921
}
925922

926923
protected cubeDependenciesProxy(parentIndex, cubeName) {

0 commit comments

Comments
 (0)