jfinkels/flask-restless — pull request #198 by franklx (2013-05-02 17:50:37+00:00)
Title: Better approach (in my opinion) to AND/OR junctions

The junction mechanism doesn't solve the nested and/or problem.

Consider the query:
```sql
SELECT *
FROM table
WHERE fld1='val1'
AND (fld2='val2' OR fld3='val3' OR (val4='val4' AND val5='val5'))
AND fld6='val6';
```
The junction mechanism doesn't provide syntax to write it like a json filter.
My method looks like an hack (because it's not intuitive) but works very well.
It uses lists to group and apply the correct conjunction/disjunction.
My implementation allow the WHERE part of the query to be written as:
```json
{
"filters": [
{"name":"fld1", "op":"eq", "val":"val1"},
[
{"name":"fld2", "op":"eq", "val":"val2"},
{"name":"fld3", "op":"eq", "val":"val3"},
[
{"name":"fld4", "op":"eq", "val":"val4"},
{"name":"fld5", "op":"eq", "val":"val5"}
]
],
{"name":"fld6", "op":"eq", "val":"val6"}
]
}
```
As you can see the or / and junction is toggled on every new level.

If you are interested in this approach I will write documentation and tests and submit and more clean pull request.