Skip to content

Commit

Permalink
fix: schemaVersion called with old context (#293)
Browse files Browse the repository at this point in the history
Fixes #294
  • Loading branch information
willhausman authored and paveltiunov committed Dec 24, 2019
1 parent 38e33ce commit da10e39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/cubejs-server-core/core/CompilerApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ class CompilerApi {
this.logger = this.options.logger;
this.preAggregationsSchema = this.options.preAggregationsSchema;
this.allowUngroupedWithoutPrimaryKey = this.options.allowUngroupedWithoutPrimaryKey;
this.schemaVersion = this.options.schemaVersion;
}

async getCompilers() {
let compilerVersion = (
this.options.schemaVersion && this.options.schemaVersion() ||
this.schemaVersion && this.schemaVersion() ||
'default_schema_version'
).toString();
if (this.options.devServer) {
Expand Down
5 changes: 4 additions & 1 deletion packages/cubejs-server-core/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,20 @@ class CubejsServerCore {
getCompilerApi(context) {
const appId = this.contextToAppId(context);
let compilerApi = this.compilerCache.get(appId);
const currentSchemaVersion = this.options.schemaVersion && (() => this.options.schemaVersion(context));
if (!compilerApi) {
compilerApi = this.createCompilerApi(
this.repositoryFactory(context), {
dbType: (dataSourceContext) => this.contextToDbType({ ...context, ...dataSourceContext }),
externalDbType: this.contextToExternalDbType(context),
schemaVersion: this.options.schemaVersion && (() => this.options.schemaVersion(context)),
schemaVersion: currentSchemaVersion,
preAggregationsSchema: this.preAggregationsSchema(context)
}
);
this.compilerCache.set(appId, compilerApi);
}

compilerApi.schemaVersion = currentSchemaVersion;
return compilerApi;
}

Expand Down

0 comments on commit da10e39

Please sign in to comment.