From e1bd92b52a70cbaaec66cb8669e16476c4881464 Mon Sep 17 00:00:00 2001 From: Dombi Attila Date: Tue, 19 Jun 2012 13:13:59 +0300 Subject: [PATCH] fix sql error when initializing models with empty Number property. It should return NULL when a number is empty --- lib/adapters/postgres.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/adapters/postgres.js b/lib/adapters/postgres.js index 8bbb8d54..52701e04 100644 --- a/lib/adapters/postgres.js +++ b/lib/adapters/postgres.js @@ -164,7 +164,18 @@ PG.prototype.toDatabase = function (prop, val) { return this.toDatabase(prop, val[0]) + ' AND ' + this.toDatabase(prop, val[1]); } } - if (prop.type.name === 'Number') return val; + if (prop.type.name === 'Number') { + if (!val) { + if( prop.autoIncrement ) { + return 'DEFAULT'; + } + else { + return 'NULL'; + } + } + return val + }; + if (prop.type.name === 'Date') { if (!val) { if( prop.autoIncrement ) {