nonzero function for the orm query class

Issue #1834 resolved
Former user created an issue

Allows you to test, if a query contains values in a more pythonic way: Old: if foo.query.count() New: if foo.query

Comments (2)

  1. Mike Bayer repo owner

    mmmm, controversial. We do make some usages of __nonzero__, i.e. where absolutely necessary i.e. with SQL expressions, though I generally like to steer clear of it since people really like using boolean tests to check for None, and I think its usually confusing to people when a non-None instance returns False. That's why we have __nonzero__ raise a huge exception for SQL expressions instead of returning True, since we by necessity have to have it return False for expressions that result from == or !=.

  2. Log in to comment