Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-894

mongoimport --upsert --type json with _id being an object does not work most of the times

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.8, 3.0.7
    • Affects Version/s: 3.0.5
    • Component/s: None
    • None
    • Environment:
      OS X 10.10.5 | mongodb 3.0.5
    • Kernel Tools 9 09/18/15
    • v3.0

      I have problems importing data into mongodb with. I have a `test.json` file like this:


      I try to import it with following command:

      mongoimport --type json --db test --collection coll --file test.json --upsert

      The import fails almost always with the same error message:

          2015-08-27T17:02:15.510+0200    error inserting documents: The _id field cannot be changed from {_id: { s: 38851448, a: 5 }} to {_id: { a: 5, s: 38851448 }}.
          2015-08-27T17:02:15.511+0200    error inserting documents: The _id field cannot be changed from {_id: { a: 5, s: 38760487 }} to {_id: { s: 38760487, a: 5 }}.

      The importer seems to change the order of the properties for `_id` for some of the documents.

      I event tried to change the order of `s` and `a` in `_id`, but the problem stays the same.

      If I trie to run the exact same import command with exactly the same datafile multiple times the documents with errors change and one time it imported all rows as expected, but just one time.

      For completeness: I'm using mongo 3.0.5 on Mac OS X 10.10.5 installed by homebrew

        1. OGh7u.png
          530 kB
        2. test.json
          0.7 kB

            kyle.erf Kyle Erf
            jfahnenbruck Jens Fahnenbruck
            0 Vote for this issue
            2 Start watching this issue