Comparing version 0.5.3 to 0.5.4
@@ -152,7 +152,7 @@ // SchemaGrammar | ||
getDefaultValue: function(value) { | ||
if (value instanceof Raw) return value.sql; | ||
if (_.isObject(value) && value.sql) return value.sql; | ||
if (value === true || value === false) { | ||
return parseInt(value, 10); | ||
value = parseInt(value, 10); | ||
} | ||
return '' + value; | ||
return "\'" + value + "\'"; | ||
}, | ||
@@ -255,3 +255,3 @@ | ||
if (column.defaultValue != void 0) { | ||
return " default '" + this.getDefaultValue(column.defaultValue) + "'"; | ||
return " default " + this.getDefaultValue(column.defaultValue); | ||
} | ||
@@ -258,0 +258,0 @@ } |
@@ -202,3 +202,3 @@ // MySQL SchemaGrammar | ||
if (column.defaultValue != void 0 && column.type != 'blob' && column.type.indexOf('text') === -1) { | ||
return " default '" + this.getDefaultValue(column.defaultValue) + "'"; | ||
return " default " + this.getDefaultValue(column.defaultValue); | ||
} | ||
@@ -205,0 +205,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
// Knex.js 0.5.3 | ||
// Knex.js 0.5.4 | ||
// -------------- | ||
@@ -91,3 +91,3 @@ | ||
// Keep in sync with package.json | ||
knex.VERSION = '0.5.3'; | ||
knex.VERSION = '0.5.4'; | ||
@@ -94,0 +94,0 @@ // Runs a new transaction, taking a container and returning a promise |
@@ -11,3 +11,3 @@ // Helpers | ||
deepClone: function(obj) { | ||
if (_.isObject(obj)) return JSON.parse(JSON.stringify(obj)); | ||
if (_.isObject(obj)) return _.cloneDeep(obj); | ||
return obj; | ||
@@ -14,0 +14,0 @@ }, |
@@ -7,2 +7,3 @@ // Schema Builder | ||
var Helpers = require('./helpers').Helpers; | ||
var Raw = require('./raw').Raw; | ||
@@ -9,0 +10,0 @@ var SchemaBuilder = function(knex) { |
{ | ||
"name": "knex", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"description": "A query builder for Postgres, MySQL and SQLite3, designed to be flexible, portable, and fun to use.", | ||
@@ -35,3 +35,5 @@ "main": "knex.js", | ||
"test": "mocha -R spec test/index.js", | ||
"doc": "groc -o docs --verbose lib/*.js lib/**/*.js clients/*.js clients/**/*.js clients/**/**/*.js knex.js" | ||
"doc": "groc -o docs --verbose lib/*.js lib/**/*.js clients/*.js clients/**/*.js clients/**/**/*.js knex.js", | ||
"release:patch": "git checkout master && export KNEX_DEV=0 && npm run-script test && npm run-script doc && git add . && git commit -m 'docs prep for release' && grunt release:patch", | ||
"release:minor": "git checkout master && export KNEX_DEV=0 && npm run-script test && npm run-script doc && git add . && git commit -m 'docs prep for release' && grunt release:minor" | ||
}, | ||
@@ -38,0 +40,0 @@ "bin": "bin/knex", |
@@ -58,3 +58,2 @@ // Helps with error handling on errors swallowed by promises. | ||
}); |
@@ -16,2 +16,16 @@ module.exports = { | ||
}, | ||
'is possible to set raw statements in defaultTo': { | ||
mysql: { | ||
bindings: [], | ||
sql: ['create table `default_raw_test` (`created_at` timestamp default CURRENT_TIMESTAMP) default character set utf8'] | ||
}, | ||
postgresql: { | ||
bindings: [], | ||
sql: ['create table "default_raw_test" ("created_at" timestamp default CURRENT_TIMESTAMP)'] | ||
}, | ||
sqlite3: { | ||
bindings: [], | ||
sql: ['create table "default_raw_test" ("created_at" datetime default CURRENT_TIMESTAMP)'] | ||
} | ||
}, | ||
'accepts the table name, and a "container" function': { | ||
@@ -18,0 +32,0 @@ mysql: { |
@@ -22,3 +22,4 @@ var Promise = testPromise; | ||
knex.schema.dropTableIfExists('migration_test_2_1'), | ||
knex.schema.dropTableIfExists('catch_test') | ||
knex.schema.dropTableIfExists('catch_test'), | ||
knex.schema.dropTableIfExists('default_raw_test') | ||
]); | ||
@@ -29,2 +30,8 @@ }); | ||
it('is possible to set raw statements in defaultTo', function() { | ||
return knex.schema.createTable('default_raw_test', function(t) { | ||
t.timestamp('created_at').defaultTo(knex.raw('CURRENT_TIMESTAMP')); | ||
}).logMe('sql').then(null); | ||
}); | ||
it('is possible to chain .catch', function() { | ||
@@ -31,0 +38,0 @@ return knex.schema.createTable('catch_test', function(t) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
246734
6432