Skip to content

Commit da10e39

Browse files
willhausmanpaveltiunov
authored andcommitted
fix: schemaVersion called with old context (#293)
Fixes #294
1 parent 38e33ce commit da10e39

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ class CompilerApi {
1111
this.logger = this.options.logger;
1212
this.preAggregationsSchema = this.options.preAggregationsSchema;
1313
this.allowUngroupedWithoutPrimaryKey = this.options.allowUngroupedWithoutPrimaryKey;
14+
this.schemaVersion = this.options.schemaVersion;
1415
}
1516

1617
async getCompilers() {
1718
let compilerVersion = (
18-
this.options.schemaVersion && this.options.schemaVersion() ||
19+
this.schemaVersion && this.schemaVersion() ||
1920
'default_schema_version'
2021
).toString();
2122
if (this.options.devServer) {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,20 @@ class CubejsServerCore {
287287
getCompilerApi(context) {
288288
const appId = this.contextToAppId(context);
289289
let compilerApi = this.compilerCache.get(appId);
290+
const currentSchemaVersion = this.options.schemaVersion && (() => this.options.schemaVersion(context));
290291
if (!compilerApi) {
291292
compilerApi = this.createCompilerApi(
292293
this.repositoryFactory(context), {
293294
dbType: (dataSourceContext) => this.contextToDbType({ ...context, ...dataSourceContext }),
294295
externalDbType: this.contextToExternalDbType(context),
295-
schemaVersion: this.options.schemaVersion && (() => this.options.schemaVersion(context)),
296+
schemaVersion: currentSchemaVersion,
296297
preAggregationsSchema: this.preAggregationsSchema(context)
297298
}
298299
);
299300
this.compilerCache.set(appId, compilerApi);
300301
}
302+
303+
compilerApi.schemaVersion = currentSchemaVersion;
301304
return compilerApi;
302305
}
303306

0 commit comments

Comments
 (0)