-
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
If I use exclude I can lose my information #1085
Comments
I'd say it's a critical issue. Still no comment?
mongoengine==0.8.7 |
mongoengine 0.10.0 does the same. looks like this happens with embedded document fields which have default values: class User(Document):
...
crm_data = me.EmbeddedDocumentField(CrmData, default=CrmData) |
Hi, Thank you for reporting the bug, I've made a test to show it (see touilleMan@cf0b28c) However I triggered it with Regarding a fix, I think the trouble is the The simpler fix would be to mimic the behavior of def exclude(self, *fields):
fields = dict([(f, QueryFieldList.EXCLUDE) for f in fields])
self.only_fields = get_all_fields() - fields.keys()
return self.fields(**fields) This mean we should find a way to retrieve the list of fields for the given collection... @MRigal any idea to do that ? The other way (much more intrusive iyam) would be to implement an |
Model: class CrmNote(EmbeddedDocument):
text = me.StringField(required=True)
author_id = me.ObjectIdField()
created_at = me.DateTimeField(default=datetime.utcnow)
class CrmData(EmbeddedDocument):
tags = me.ListField(me.StringField(min_length=2, max_length=20))
notes = me.ListField(me.EmbeddedDocumentField(CrmNote))
class User(Document):
crm_data = me.EmbeddedDocumentField(CrmData, default=CrmData)
... |
If I use
exclude
I can lose my information. Here is what happens in my auth middleware:The text was updated successfully, but these errors were encountered: