You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This bug already existed some time ago (#1058) and there was even a bugfix for it (#1088) but I'm still experiencing this issue..
The bugfix doesn't work for me and I think the test case is not written in a correct way. I'm not sure but it looks like the DictField is auto-dereferenced if it's loaded from the database - which never happens in the test case.
The _auto_dereference setting for the DictField is just ignored and overridden, which causes strange behaviour when accessing the field. First it looks like it's a normal instance of a Document, then it's a list with just the property names.
The text was updated successfully, but these errors were encountered:
I just found another issue caused by this bug.. Saving the same document more than one time doesn't work because it replaces the DictField value with a DBRef, which causes validation to fail at the second save.
class House(me.Document):
address = me.StringField()
meta = {'allow_inheritance': True}
class Person(me.Document):
age = me.IntField()
Person(age=79).save()
# Let's force a house document in the person collection
dumped_house = House(address='garbage').to_mongo().to_dict()
Person._get_collection().insert_one(dumped_house)
print list(Person.objects()) # [<Person: Person object>, <House: House object>]
This bug already existed some time ago (#1058) and there was even a bugfix for it (#1088) but I'm still experiencing this issue..
The bugfix doesn't work for me and I think the test case is not written in a correct way. I'm not sure but it looks like the DictField is auto-dereferenced if it's loaded from the database - which never happens in the test case.
I was able to track down the issue to it's root cause, which is here: https://github.com/MongoEngine/mongoengine/blob/master/mongoengine/base/document.py#L705
The _auto_dereference setting for the DictField is just ignored and overridden, which causes strange behaviour when accessing the field. First it looks like it's a normal instance of a Document, then it's a list with just the property names.
The text was updated successfully, but these errors were encountered: