fix sql error when initializing models with empty Number property. It should return NULL when a number is empty

This commit is contained in:
Dombi Attila 2012-06-19 13:13:59 +03:00
parent 9e2b9e1272
commit e1bd92b52a
1 changed files with 12 additions and 1 deletions

View File

@ -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 ) {