From d5b00033500c061302172daeb1cf843e1b307730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Drouyer?= Date: Sat, 27 Oct 2012 20:47:25 +0200 Subject: [PATCH] Fixed postgres adapter for IN and NIN when values are strings and where there is 0 value --- lib/adapters/postgres.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/adapters/postgres.js b/lib/adapters/postgres.js index 1e634de1..4eefe8ac 100644 --- a/lib/adapters/postgres.js +++ b/lib/adapters/postgres.js @@ -164,6 +164,12 @@ PG.prototype.toDatabase = function (prop, val) { if (operator === 'between') { 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 (!val && val!=0) { @@ -239,6 +245,10 @@ PG.prototype.toFilter = function (model, filter) { } else if (conds[key].constructor.name === 'Object') { var condType = Object.keys(conds[key])[0]; var sqlCond = '"' + key + '"'; + if ((condType == 'inq' || condType == 'nin') && filterValue.length == 0) { + fields.push(condType == 'inq' ? 'FALSE' : 'TRUE'); + return true; + } switch (condType) { case 'gt': sqlCond += ' > ';