Uploaded image for project: 'MongoDB CLI Tools'
  1. MongoDB CLI Tools
  2. TOOLS-899

mongoimport changes field order on custom IDs

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 3.0.4
    • Fix Version/s: None
    • Component/s: mongoimport
    • Labels:
    • Environment:
      $ lsb_release -a
      No LSB modules are available.
      Distributor ID: Debian
      Description: Debian GNU/Linux 7.8 (wheezy)
      Release: 7.8
      Codename: wheezy

      Description

      When importing JSON files, mongoimport will randomly change the order of custom ID fields. Specifically, documents exported with mongoexport, then imported again with mongoimport will not end up identical. Since field order matters in mongoDB, these "shuffled" documents are not found anymore by our software, creating all kinds of problems. mongoimport is unusable for us as of now.

      To reproduce, import the attached JSON file:

      mongoimport -d test -c test --file test.json

      The result is different every time. Here's one example:

      > db.test.find();
      { "_id" :

      { "a" : "index", "b" : 1, "c" : 3 }

      , "d" : "test" }
      { "_id" :

      { "a" : "index", "b" : 1, "c" : 2 }

      , "d" : "test" }
      { "_id" :

      { "a" : "index", "b" : 2, "c" : 2 }

      , "d" : "test" }
      { "_id" :

      { "c" : 3, "a" : "index", "b" : 2 }

      , "d" : "test" }
      { "_id" :

      { "a" : "index", "b" : 3, "c" : 1 }

      , "d" : "test" }
      { "_id" :

      { "b" : 3, "c" : 2, "a" : "index" }

      , "d" : "test" }
      { "_id" :

      { "a" : "index", "b" : 1, "c" : 1 }

      , "d" : "test" }
      { "_id" :

      { "a" : "index", "b" : 2, "c" : 1 }

      , "d" : "test" }
      { "_id" :

      { "a" : "index", "b" : 3, "c" : 3 }

      , "d" : "test" }

      Notice line 4 and 6 where the field order is wrong.

      This behaviour was not observed in 2.x versions (although I cannot confirm at the moment).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kyle.erf Kyle Erf
                Reporter:
                rivo Oliver
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: