嘿伙计们,我想弄清楚如何为以下情况构建我的查询
首先我定义了一个模型
class Variant(ndb.Expando):
test = ndb.StringProperty()
class Item(ndb.Model):
test2 = ndb.StringProperty()
variants = ndb.StructuredProperty(Variant, repeated=True)
variant = Variant(test="test", dynamic="a")
item = Item(test2="test", variants=[variant, ])
item.put()
然后是查询的东西..到目前为止我已经尝试过
dynamic = "dynamic"
Item.query(ndb.GenericProperty("variants.%s" % dynamic) == "a")
Item.query(Item._properties["variants.%s" % dynamic] == "a")
Item.query(getattr(Item.variants, dynamic) == "a")
Item.query(getattr(Item, "variants.%s" % dynamic) == "a")
Item.query(ndb.query.FilterNode("variants.%s" % dynamic, "=", "a"))
generic_prop = ndb.GenericProperty()
generic_prop._name = "variants.%s" % dynamic
Item.query(generic_prop == "a")
这些都不起作用。这应该是完全可能的,因为数据存储中的属性名称是
variants.dynamic = ["a", ]
感谢您的帮助