Skip to content

Commit

Permalink
mssql dialect: make createTableIfNotExists actually work.
Browse files Browse the repository at this point in the history
Previously it would never actually create the table, as
object_id() returns null if the table doesn't exist
  • Loading branch information
wolfgang42 authored and Wolfgang Faust committed Apr 21, 2016
1 parent 85403e8 commit aa3c1c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/dialects/mssql/schema/tablecompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ assign(TableCompiler_MSSQL.prototype, {

createAlterTableMethods: ['foreign', 'primary', 'unique'],
createQuery: function (columns, ifNot) {
var createStatement = ifNot ? 'if object_id(\'' + this.tableName() + '\', \'U\') is not null CREATE TABLE ' : 'CREATE TABLE ';
var createStatement = ifNot ? 'if object_id(\'' + this.tableName() + '\', \'U\') is null CREATE TABLE ' : 'CREATE TABLE ';
var sql = createStatement + this.tableName() + (this._formatting ? ' (\n ' : ' (') + columns.sql.join(this._formatting ? ',\n ' : ', ') + ')';

if (this.single.comment) {
Expand Down

0 comments on commit aa3c1c2

Please sign in to comment.