analog of query.filter() for OR operation

Issue #926 resolved
Former user created an issue

currently query.filter()/filter_by() can be put one after another, which does "AND" of the conditions - e.g. criterion = criterion & new.

How about a way to "OR" them? so criterion = criterion | new

e.g. one can use query.this.that.filter(a==1).whatever.or_filter(a>=3)

'' How would you specify the logical "parenthesis" to control evaluation order in complex expressions? '' maybe something like joinpoint? i.e. a semi-explicit ".parenthnesis()" of sorts...

Comments (2)

  1. Mike Bayer repo owner

    filter() is used in a generative style to add limiting criterion to a set of results. a filter that appends criterion based on "OR" would not be adding a limit, it would be adding an expansion; and without the ability to create groupings is not very useful. schemes using more method calls like ".parenthesis()" would be confusing as one would have to mentally track the "count" of parenthesis to use correctly.

    Whereas the existing or_() and | operators are already easy to use and allow the user to use parenthesis directly.

  2. Mike Bayer repo owner

    the original need here was because join('foo', aliased=True) could not be "or-ed" with another aliased join on the same path. the aliased() construct in 0.5 eliminates this issue.

  3. Log in to comment