2011-10-11 26 views
2

假設一個NDB(版本0.7 & 0.8)與主要模型可以是無:如何查詢Model.KeyProperty ==沒有在數據存儲加(NDB)

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?

回答

1

這看起來像NDB中的一個錯誤。你可以在問題追蹤器上提交一個嗎?

+0

好的。我提交了http://code.google.com/p/appengine-ndb-experiment/issues/detail?id=77 :) –