mongoengine
mongoengine copied to clipboard
EmbeddedDocumentList in nested embededded document save() does not find the parent document
save() not working in an EmbeddedDocumentList in nested embedded document, as _instance is an EmbeddedDocument instead of Document
Reproducer:
class TestK2(EmbeddedDocument):
values = EmbeddedDocumentListField(StringField, default=[])
class TestK1(EmbeddedDocument):
k2 = EmbeddedDocumentField(TestK2)
class Main(Document):
part = EmbeddedDocumentField(TestK1)
def main():
main = Part()
main.part.k1.k2.values.save() # AttributeError: TestK1 has no attribute 'save'
I would assume that nested EmbeddedDocuments should have _instance pointing to the Document instance and _parent pointing to the parent doc (embedded or actual document)