Skip to content

DictField is auto-dereferenced if storing data containing _cls property #1398

Open
@robertaistleitner

Description

@robertaistleitner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions