Skip to content
Browse files

Allow for IN, NOT IN, and != queries in postgres

  • Loading branch information...
1 parent 6d33aaa commit c3dd47f44833f41c46f0c94af110dc50f60a46f0 @mhuggins mhuggins committed Sep 13, 2012
Showing with 20 additions and 11 deletions.
  1. +20 −11 lib/adapters/postgres.js
View
31 lib/adapters/postgres.js
@@ -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 c3dd47f

Please sign in to comment.
Something went wrong with that request. Please try again.