Skip to content

Commit 16b8c87

Browse files
committed
fix: MS SQL has unusual CREATE SCHEMA syntax
Fixes #185
1 parent e31a80c commit 16b8c87

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/cubejs-mssql-driver/driver/MSSqlDriver.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ class MSSqlDriver extends BaseDriver {
6060
param(paramIndex) {
6161
return `@_${paramIndex + 1}`;
6262
}
63+
64+
createSchemaIfNotExists(schemaName) {
65+
return this.query(
66+
`SELECT schema_name FROM information_schema.schemata WHERE schema_name = ${this.param(0)}`,
67+
[schemaName]
68+
).then((schemas) => {
69+
if (schemas.length === 0) {
70+
return this.query(`CREATE SCHEMA ${schemaName}`);
71+
}
72+
return null;
73+
});
74+
}
6375
}
6476

6577
module.exports = MSSqlDriver;

0 commit comments

Comments
 (0)