Permalink
Browse files

Merge pull request #121 from mhuggins/postgres-in

Allow for IN, NOT IN, and != queries in PostgreSQL
  • Loading branch information...
2 parents 6d33aaa + c3dd47f commit 4ce4a0bc2cd47ef34caad1e3ee0ee60e97a673e4 @1602 committed Sep 14, 2012
Showing with 20 additions and 11 deletions.
  1. +20 −11 lib/adapters/postgres.js
View
@@ -229,22 +229,31 @@ PG.prototype.toFilter = function (model, filter) {
var sqlCond = key;
switch (condType) {
case 'gt':
- sqlCond += ' > ';
- break;
+ sqlCond += ' > ';
+ break;
case 'gte':
- sqlCond += ' >= ';
- break;
+ sqlCond += ' >= ';
+ break;
case 'lt':
- sqlCond += ' < ';
- break;
+ sqlCond += ' < ';
+ break;
case 'lte':
- sqlCond += ' <= ';
- break;
+ sqlCond += ' <= ';
+ break;
case 'between':
- sqlCond += ' BETWEEN ';
- break;
+ sqlCond += ' BETWEEN ';
+ break;
+ case 'inq':
+ sqlCond += ' IN ';
+ break;
+ case 'nin':
+ sqlCond += ' NOT IN ';
+ break;
+ case 'neq':
+ sqlCond += ' != ';
+ break;
}
- sqlCond += filterValue;
+ sqlCond += (condType == 'inq' || condType == 'nin') ? '(' + filterValue + ')' : filterValue;
fields.push(sqlCond);
} else {
fields.push('"' + key + '" = ' + filterValue);

0 comments on commit 4ce4a0b

Please sign in to comment.