Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-596

Dictionaries do not preserve order

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Environment:
      Ubuntu 13.10/x86_64

      I insert a dictionary of values in a mongo document. The order in which I insert them in a BsonDocument (from the C# driver) is preserved in the database, however, while consuming the document, Python dictionaries do not preserve the order of the keys, as it preserves them in alphabetical or numeric order by default.

      This forces me to sort things after I queried (which forces me to make assumptions about which items are on that dictionary), making my app a little less dynamic.

      I suggest that on Mongo responses, Mongo should have a dictionary subclass or a dictionary like class that preserves the order of the keys while retrieving a dictionary from a document.

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            aruiz Alberto Ruiz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: