mongoengine
mongoengine copied to clipboard
Query MapField by a key that matches one of the field names in the nested document fails with a mongoengine.errors.InvalidQueryError
Here is the class hierarchy:
class DataItem(EmbeddedDocument):
key = StringField(required=True)
value = StringField(required=True)
class MyDoc(Document):
data = MapField(
field=EmbeddedDocumentField(DataItem)
)
And the data in db:
{
"_id" : ObjectId("63a87cb374d6bc3efd9ea570"),
"data" : {
"key" : {
"key" : "1",
"value" : "test"
}
}
}
{
"_id" : ObjectId("63a87cb374d6bc3efd9ea571"),
"data" : {
"a" : {
"key" : "2",
"value" : "test"
}
}
}
The query MyDoc.objects(data__a__value="test").first()
succeeds while the query MyDoc.objects(data__key__value="test").first()
fails with mongoengine.errors.InvalidQueryError: Cannot resolve field "value"
Any update on this? Happens with MongoEngine 0.24.2