diff --git a/lib/mysql.js b/lib/mysql.js index 38d76aa..135e448 100644 --- a/lib/mysql.js +++ b/lib/mysql.js @@ -324,6 +324,9 @@ MySQL.prototype.toDatabase = function (prop, val, forCreate) { return this.client.escape(val); } if (prop.type === Number) { + if (isNaN(val)) { + val = null; + } return this.client.escape(val); } if (prop.type === Date) { @@ -925,7 +928,7 @@ MySQL.prototype.propertiesSQL = function (model) { if (pks.length === 1) { var idName = this.idName(model); var idProp = this._models[model].properties[idName]; - if(idProp.generated) { + if (idProp.generated) { sql.push(self.columnEscaped(model, idName) + ' INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY'); } else { idProp.nullable = false; diff --git a/package.json b/package.json index 1392c29..2a4506e 100644 --- a/package.json +++ b/package.json @@ -8,15 +8,16 @@ }, "dependencies": { "loopback-connector": "1.x", - "mysql": "~2.5.0", - "async": "~0.9.0", - "debug": "~2.0.0" + "mysql": "^2.5.4", + "async": "^0.9.0", + "debug": "^2.1.1" }, "devDependencies": { - "loopback-datasource-juggler": "^2.15.0", - "should": "~1.3.0", - "mocha": "~1.20.1", - "rc": "~0.4.0" + "bluebird": "~2.9.10", + "loopback-datasource-juggler": "^2.17.0", + "mocha": "^2.1.0", + "rc": "^0.6.0", + "should": "^5.0.0" }, "repository": { "type": "git", diff --git a/test/mysql.test.js b/test/mysql.test.js index af1c3dc..c4c5a96 100644 --- a/test/mysql.test.js +++ b/test/mysql.test.js @@ -197,7 +197,7 @@ describe('mysql', function () { posts.should.have.lengthOf(1); post = posts[0]; post.should.have.property('title', 'b'); - post.should.not.have.property('content'); + post.should.have.property('content', undefined); should.not.exist(post.id); done();