balderdashy/sails-postgresql — pull request #37 by grownseed (2014-01-30 19:02:59+00:00)
Title: Nasty fix for OR operator being applied instead of AND

This is a rather nasty fix for `OR` operators being used instead of `(...) AND`. See issue #28.

Ideally, I think `where()` should work recursively and use something along the lines of nested arrays instead of concatenating strings as it goes. Each array would end up as `(...)` in the final query, so that something like the following would work:

```javascript
{
or: [
field1: 'value',
{like: {field2: '%value%'}},
and: [
field3: 'value',
field4: 'value'
]
],
field5: 'value'
}
```

which would give something like:

```sql
[...] WHERE (field1 = 'value' OR field2 LIKE '%value%' OR (field3 = 'value' AND field4 = 'value')) AND field5 = 'value';
```