Hi all,
I am having trouble trying to do a keys only query in python, using the same db.Query object.
Its able to fetch the key for the first query but none for the second althought the property is valid.
but it works fine if I create a new object and use it. Please find the usecase below.
#This is my model
class Test(db.Model):
name = db.StringProperty()
b1 = Test.all().filter('name','abc').get()
b2 = Test.all().filter('name','def').get()
print b1.bizname #This prints :abc
print b2.bizname #This prints :def
#creating a keys only query
#and filtering on same query object(here q)
q = db.Query(model_class=TestModel.Biz, keys_only=True)
b3 = q.filter('name', 'abc').get()
b4 = q.filter('name', 'def').get()
print b3 #prints the key
print b4 #prints None
# the same as above with abc and def reversed
q = db.Query(model_class=TestModel.Biz, keys_only=True)
b7 = q.filter('name', 'def').get()
b8 = q.filter('name', 'abc').get()
print b7 #prints the key
print b8 #prints None
#doing the same thing with different query object
q1 = db.Query(model_class=biz_model.Biz, keys_only=True)
b5 = q1.filter('name', 'abc').get()
q2 = db.Query(model_class=biz_model.Biz, keys_only=True)
b6 = q2.filter('name', 'def').get()
print b5 #prints the key
print b6 #prints the key
Any explanation will be greatly appreciated.
regards,
Joy