nonzero function for the orm query class
Issue #1834
resolved
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)
-
repo owner -
repo owner - changed status to wontfix
since I'm -1 on this and nobody has chimed in, closing this.
- Log in to comment
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 forNone
, and I think its usually confusing to people when a non-None
instance returnsFalse
. That's why we have__nonzero__
raise a huge exception for SQL expressions instead of returningTrue
, since we by necessity have to have it returnFalse
for expressions that result from==
or!=
.