The documentation states that query.count() should be equivalent to (but more efficient than) len(query.fetch()). I believe that I have found a corner case where this is not true.
For my application, I have a query with the following filter structure (obtained while running unit-tests with the gae testbed):
I get different results when trying to count the results vs. trying to fetch them. FWIW, I originally really only cared if there was one or more items, so I've switched to code to .get() the result versus .count. With query.get(), my unit-test passes once again, however, with query.get(keys_only=True) my unit-tests begin to fail again. I've tried to reconstruct this in a simpler unit-test but I haven't been able to do so easily. e.g. the following query filter structure seems to work OK:
This leads me to believe that the problem is in the PostFilterNode. Thinking about it, it would make sense that a keys-only query would fail if there needs to be in-memory filtering. I would expect that a sensible exception should be raised in this case -- e.g. 'The query that you've requested does not support "keys_only"' or something to that effect.
The documentation states that
query.count()
should be equivalent to (but more efficient than)len(query.fetch())
. I believe that I have found a corner case where this is not true.For my application, I have a query with the following filter structure (obtained while running unit-tests with the gae testbed):
I get different results when trying to count the results vs. trying to fetch them. FWIW, I originally really only cared if there was one or more items, so I've switched to code to
.get()
the result versus.count
. Withquery.get()
, my unit-test passes once again, however, withquery.get(keys_only=True)
my unit-tests begin to fail again. I've tried to reconstruct this in a simpler unit-test but I haven't been able to do so easily. e.g. the following query filter structure seems to work OK:This leads me to believe that the problem is in the
PostFilterNode
. Thinking about it, it would make sense that a keys-only query would fail if there needs to be in-memory filtering. I would expect that a sensible exception should be raised in this case -- e.g. 'The query that you've requested does not support "keys_only"' or something to that effect.