Fixed postgres adapter for IN and NIN when values are strings and where there is 0 value

This commit is contained in:
Sébastien Drouyer 2012-10-27 20:47:25 +02:00
parent f17716272c
commit d5b0003350
1 changed files with 10 additions and 0 deletions

View File

@ -164,6 +164,12 @@ PG.prototype.toDatabase = function (prop, val) {
if (operator === 'between') { if (operator === 'between') {
return this.toDatabase(prop, val[0]) + ' AND ' + this.toDatabase(prop, val[1]); return this.toDatabase(prop, val[0]) + ' AND ' + this.toDatabase(prop, val[1]);
} }
if (operator === 'inq' || operator === 'nin') {
for (var i = 0; i < val.length; i++) {
val[i] = escape(val[i]);
}
return val.join(',');
}
} }
if (prop.type.name === 'Number') { if (prop.type.name === 'Number') {
if (!val && val!=0) { if (!val && val!=0) {
@ -239,6 +245,10 @@ PG.prototype.toFilter = function (model, filter) {
} else if (conds[key].constructor.name === 'Object') { } else if (conds[key].constructor.name === 'Object') {
var condType = Object.keys(conds[key])[0]; var condType = Object.keys(conds[key])[0];
var sqlCond = '"' + key + '"'; var sqlCond = '"' + key + '"';
if ((condType == 'inq' || condType == 'nin') && filterValue.length == 0) {
fields.push(condType == 'inq' ? 'FALSE' : 'TRUE');
return true;
}
switch (condType) { switch (condType) {
case 'gt': case 'gt':
sqlCond += ' > '; sqlCond += ' > ';