Skip to content

Commit 502480c

Browse files
committed
fix: TypeError: (queryOptions.dialectClass || ADAPTERS[dbType]) is not a constructor
1 parent beb75df commit 502480c

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

packages/cubejs-server-core/core/CompilerApi.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@ class CompilerApi {
5555
async getSql(query, options) {
5656
options = options || {};
5757
const { includeDebugInfo } = options;
58-
const dbType = this.getDbType('default');
59-
const dialectClass = this.getDialectClass('default');
58+
const dbType = this.getDbType();
6059
const compilers = await this.getCompilers({ requestId: query.requestId });
61-
let sqlGenerator = this.createQuery(compilers, dbType, dialectClass, query);
60+
let sqlGenerator = this.createQueryByDataSource(compilers, query);
6261
if (!sqlGenerator) {
6362
throw new Error(`Unknown dbType: ${dbType}`);
6463
}
@@ -67,11 +66,10 @@ class CompilerApi {
6766

6867
if (dataSource !== 'default' && dbType !== this.getDbType(dataSource)) {
6968
// TODO consider more efficient way than instantiating query
70-
sqlGenerator = this.createQuery(
69+
sqlGenerator = this.createQueryByDataSource(
7170
compilers,
72-
this.getDbType(dataSource),
73-
this.getDialectClass(dataSource),
74-
query
71+
query,
72+
dataSource
7573
);
7674
}
7775

@@ -96,6 +94,10 @@ class CompilerApi {
9694
return cubeEvaluator.scheduledPreAggregations();
9795
}
9896

97+
createQueryByDataSource(compilers, query, dataSource) {
98+
return this.createQuery(compilers, this.getDbType(dataSource), this.getDialectClass(dataSource), query);
99+
}
100+
99101
createQuery(compilers, dbType, dialectClass, query) {
100102
return QueryBuilder.query(
101103
compilers,

packages/cubejs-server-core/core/RefreshScheduler.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ class RefreshScheduler {
66
}
77

88
async refreshQueriesForPreAggregation(context, compilerApi, preAggregation, queryingOptions) {
9-
const dbType = compilerApi.getDbType();
109
const compilers = await compilerApi.getCompilers();
11-
const query = compilerApi.createQuery(compilers, dbType, queryingOptions);
10+
const query = compilerApi.createQueryByDataSource(compilers, queryingOptions);
1211
if (preAggregation.preAggregation.partitionGranularity) {
1312
const dataSource = query.cubeDataSource(preAggregation.cube);
1413

@@ -45,7 +44,7 @@ class RefreshScheduler {
4544
dateRange
4645
}]
4746
};
48-
const partitionQuery = compilerApi.createQuery(compilers, dbType, baseQuery);
47+
const partitionQuery = compilerApi.createQueryByDataSource(compilers, baseQuery);
4948
const { partitionDimension } = partitionQuery.preAggregations.partitionDimension(preAggregation);
5049
return partitionDimension.timeSeries().map(range => ({
5150
...baseQuery,
@@ -116,9 +115,8 @@ class RefreshScheduler {
116115
}
117116

118117
async refreshCubesRefreshKey(context, compilerApi, queryingOptions) {
119-
const dbType = compilerApi.getDbType();
120118
const compilers = await compilerApi.getCompilers();
121-
const queryForEvaluation = compilerApi.createQuery(compilers, dbType, {});
119+
const queryForEvaluation = compilerApi.createQueryByDataSource(compilers, {});
122120
await Promise.all(queryForEvaluation.cubeEvaluator.cubeNamesWithRefreshKeys().map(async cube => {
123121
const cubeFromPath = queryForEvaluation.cubeEvaluator.cubeFromPath(cube);
124122
const measuresCount = Object.keys(cubeFromPath.measures || {}).length;

0 commit comments

Comments
 (0)