-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field where class field name != document field name is not being updated to database #1178
Comments
tl;dr when you implement a getter/setter for a field on a mongoengine document, remember that Not sure if this is a real issue. Your implementation of
It prints:
So initializing with
Prints correctly:
|
See the attached for sample code and a dump of the query log.
When I create a field within a class, and that field is bound to a differently named field in the database document (using the db_field option), then updates to that field are not written to the database. The update query does not include that field, although it does include any other fields that need to be written.
The save() method returns a success, and the object instance does have the changes, but the database itself does not.
Examining the query log shows that the updateobj does indeed not have the field with the name 'mismatch', and thus data is not written to the database.
My workaround is to call
_mark_as_changed(<name of field in class>)
on the document to force this field to be added to the list of fields to be updated.not_updating.zip
The text was updated successfully, but these errors were encountered: