MongoEngine / mongoengine

A Python Object-Document-Mapper for working with MongoDB
http://mongoengine.org
MIT License
4.24k stars 1.23k forks source link

OrderedDict support in mongoengine ? #203

Open m-vdb opened 11 years ago

m-vdb commented 11 years ago

Hi,

As PyMongo supports the OrderedDict through SON objects (http://api.mongodb.org/python/current/api/bson/son.html?highlight=bson.son#bson.son.SON), is anyone thinking about the possibility to support this in MongoEngine ?

Cheers,

rozza commented 11 years ago

Happy to take a pull request for this :)

MRigal commented 9 years ago

This will remain out-of-scope as long as we support Python < 2.7

justingiorgi commented 9 years ago

I disagree that this is out of scope due to support of < 2.7. It should be possible to utilize the OrderedDict class when it is available and disable support or use an alternate implementation when it isn't. It seems that the DynamicField class already preserves order when inserting data but loses order when extracting that data.

My team and I are migrating an application from pymongo to mongoengine. We have a few documents that require ordered dictionary / subdocument fields. I'll take a look at this problem and submit a pull request if I'm able to solve it.

MRigal commented 9 years ago

OK, I'm actually fine with it and even more happy if you come out with a proper solution also compatible with Python 2.6 ! I'll review your PR with pleasure :-)

userlocalhost commented 7 years ago

In previous discussion, this feature was hard to implement because of the compatibility for Python2.6. But from the v0.11.0 release, the support of Python2.6 is dropped. So I implemented this feature.

Thank you.

EmcoreYueLi commented 7 years ago

Is this feature released? I did not see the OrderedDynamicField in mongoengine-0.13.0

bagerard commented 6 years ago

Just to clarify, the feature wasn't released (in fact the PR got merged but then the commit got reverted)