Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dictionary becomes BaseList in MongoEngine after assignement

I'm using mongoengine 0.9.0

class EntityChange(Document):
    ...
    old_data = DictField()
    new_data = DictField()

I want to save dict objects into old_data and new_data.

Why are fields becoming BaseList after assignment?

data = {u'int_id': 100500, u'_cls': 'BuildingKind', ...}
instance = EntityChange()
instance.new_data = data
# after that
# isinstance(instance, BaseList) is True
# isinstance(instance, BaseDict) is False
# instance.new_data == ['int_id', 'id', ...] is True. why?
like image 604
orion_tvv Avatar asked Oct 20 '22 10:10

orion_tvv


1 Answers

Passing a dict containing _cls or _types triggered a bug in mongoengine.

A fix has been submitted and was merged in versions 0.10.1 and later.

like image 188
Nils Werner Avatar answered Oct 22 '22 01:10

Nils Werner