Ndb Query Builder Doesn't Work As Expected
I have the following query in my application query = cls.query().filter(cls.taskgroup_id == taskgroup_id, cls.availability == True, cls.task_id > min_task_id).order(cls.task_id)
Solution 1:
From Filtering by Property Values (emphasis mine):
query = Account.query(Account.userid >= 40, Account.userid < 50)[...]
Instead of specifying an entire query filter in a single expression, you may find it more convenient to build it up in steps: for example:
appengine/standard/ndb/queries/snippets.py
query1 = Account.query() # Retrieve all Account entititesquery2 = query1.filter(Account.userid >= 40) # Filter on userid >= 40query3 = query2.filter(Account.userid < 50) # Filter on userid < 50 too
query3is equivalent to thequeryvariable from the previous example. Note that query objects are immutable, so the construction ofquery2does not affectquery1and the construction ofquery3does not affectquery1orquery2.
In other words for your example none of the query.filter() statements actually modifies query.
Just assign the results of the statements to local variables and use those instead, just as in the quoted example.
Post a Comment for "Ndb Query Builder Doesn't Work As Expected"