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

mongoimport imports fields with dots (.) from JSON

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 3.2.7
    • Fix Version/s: No versions
    • Component/s: mongoimport
    • Labels:
      None

      Description

      mongoimport allows fields with dots "." to be imported

      An input file as:

      { "a.b" : 1 }
      { "a.b" : 2 }
      

      is imported without errors/warnings:

      $ mongoimport -d test -c test import.json
      connected to: 127.0.0.1
      2016-07-18T10:58:58.382+1000 imported 2 objects
      $
      

      The collection looks like:

      {
        "_id": ObjectId("578ec46e39b3c19fbbeb2264"),
        "a.b": 1
      }
      {
        "_id": ObjectId("578ec46e39b3c19fbbeb2262"),
        "a.b": 2
      }
      

      Testing with 3.2.7, 3.0.8, 2.6.11 and 2.4.14 produced the same results.

      Only 2.5.2 shows errors when importing:

      $ mongoimport -d test -c test import.json
      connected to: 127.0.0.1
      2016-07-18T10:56:05.626+1000 error: Cannot insert object with _id field of array/regex or with any field name prefixed with $ or containing a dot.
      2016-07-18T10:56:05.627+1000 error: Cannot insert object with _id field of array/regex or with any field name prefixed with $ or containing a dot.
      2016-07-18T10:56:05.627+1000 tried to import 2 objects
      2016-07-18T10:56:05.627+1000 ERROR: encountered at least 2 error(s)s
      $
      

      Both TOOLS-57 and TOOLS-64 say that they should be imported as an embedded object but this doesn't seem to be the case.

      In addition, once the documents are imported, they cannot be $renamed due to SERVER-25164

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-server-tools Backlog - Server Tools Team
              Reporter:
              amar.hamzeh Amar Hamzeh
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: