gpt4 book ai didi

python - 如何在 Datastore Plus(NDB) 中查询 Model.KeyProperty == None

转载 作者:太空宇宙 更新时间:2023-11-04 06:26:23 24 4
gpt4 key购买 nike

假设一个 NDB(版本 0.7 和 0.8)模型,其键可以是 None:

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

只有使用 None 过滤键才会抛出错误。

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'

如何使用 None 查询 KeyProperty?

最佳答案

这看起来像是 NDB 中的一个错误。你能在问题跟踪器上提交一份吗?

关于python - 如何在 Datastore Plus(NDB) 中查询 Model.KeyProperty == None,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7724252/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com