Skip to content

Conversation

@mcsimps2
Copy link
Contributor

@mcsimps2 mcsimps2 commented Apr 10, 2025

In order to allow setting new fields that did not previouly exist on dynamic embedded documents, the lookup_member functions on EmbeddedDocumentField and GenericEmbeddedDocumentField return dynamic fields as appropriate. Special awareness is given to positional operators - see the new test cases for examples of where this is important.

Here's an example of what this now allows

class Wheel(DynamicEmbeddedDocument): position = StringField() class Car(Document): wheels = EmbeddedDocumentListField(Wheel) # This is now allowed - adding a new field to the dynamic embedded document Car.objects(wheels__position="front-driver").update( set__wheels__S__damaged=True ) 

Resolves #2486

In order to allow setting new fields that did not previouly exist on dynamic embedded documents, the `lookup_member` functions on `EmbeddedDocumentField` and `GenericEmbeddedDocumentField` return dynamic fields as appropriate. This enables operations like `A.objects(...).update(foo__newfield="bar")`. Resolves MongoEngine#2486
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant