Предположим, модель NDB (версии 0.7 и 0.8) с ключом, который может быть Нет:
class Test(model.Model):
k = model.KeyProperty()
value = model.IntegerProperty()
count = Test.query(Test.k == None).count() # error
#count = Test.query(Test.k != None).count() # error also
Только ключ фильтрации с ошибкой Нет.
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/_webapp25.py", line 701, in __call__
handler.get(*groups)
File "/Users/reiot/Documents/Works/ndbtest/main.py", line 91, in get
count = Test.query(Test.k == None).count() # error
File "/Users/reiot/Documents/Works/ndbtest/ndb/model.py", line 500, in __eq__
return self._comparison('=', value)
File "/Users/reiot/Documents/Works/ndbtest/ndb/model.py", line 491, in _comparison
return FilterNode(self._name, op, self._datastore_type(value))
File "/Users/reiot/Documents/Works/ndbtest/ndb/model.py", line 1138, in _datastore_type
return datastore_types.Key(value.urlsafe())
AttributeError: 'NoneType' object has no attribute 'urlsafe'
Как я могу запросить KeyProperty с None?