Skip to content

Commit

Permalink
fix: MS SQL has unusual CREATE SCHEMA syntax
Browse files Browse the repository at this point in the history
Fixes #185
  • Loading branch information
paveltiunov committed Aug 17, 2019
1 parent e31a80c commit 16b8c87
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/cubejs-mssql-driver/driver/MSSqlDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ class MSSqlDriver extends BaseDriver {
param(paramIndex) {
return `@_${paramIndex + 1}`;
}

createSchemaIfNotExists(schemaName) {
return this.query(
`SELECT schema_name FROM information_schema.schemata WHERE schema_name = ${this.param(0)}`,
[schemaName]
).then((schemas) => {
if (schemas.length === 0) {
return this.query(`CREATE SCHEMA ${schemaName}`);
}
return null;
});
}
}

module.exports = MSSqlDriver;

0 comments on commit 16b8c87

Please sign in to comment.