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

mongoexport problem on data with quotes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker - P1
    • Resolution: Fixed
    • Affects Version/s: 3.2.1
    • Fix Version/s: 3.2.2, 3.0.10, 3.3.1
    • Component/s: mongoexport
    • Labels:
      None
    • Environment:
      OSX, Amazon Linux
    • Backport Requested:
      v3.2, v3.0
    • Sprint:
      Server Tools F (01/29/16)

      Description

      This is a regression from 2.6.x.

      > db.artists.insert({ "name" : "Andy Warhol", "genome" :

      { "Pop Art" : 10 }

      })
      WriteResult(

      { "nInserted" : 1 }

      )

      > db.artists.insert({ "name" : "Quoted Andy Warhol", "genome" :

      { "\"Pop Art\"" : 10 }

      })
      Cannot use 'commands' readMode, degrading to 'legacy' mode
      WriteResult(

      { "nInserted" : 1 }

      )

      > db.artists.find()
      { "_id" : ObjectId("5699157cc42b4297c59e8165"), "name" : "Andy Warhol", "genome" :

      { "Pop Art" : 10 }

      }
      { "_id" : ObjectId("56991584c42b4297c59e8166"), "name" : "Quoted Andy Warhol", "genome" :

      { ""Pop Art"" : 10 }

      }

      > exit
      bye

      /tmp$ mongoexport --db test -c artists
      2016-01-15T10:51:52.266-0500 connected to: localhost
      {"_id":

      {"$oid":"5699157cc42b4297c59e8165"}

      ,"name":"Andy Warhol","genome":{"Pop Art":10.0}}
      2016-01-15T10:51:52.284-0500 Failed: json: error calling MarshalJSON for type bsonutil.MarshalD: cannot marshal [

      {"Pop Art" 10}

      ]: json: error calling MarshalJSON for type bsonutil.MarshalD: invalid character 'P' after object key

        Issue Links

          Activity

          Hide
          dblock Daniel Doubrovkine added a comment - - edited

          The above didn't quite render right. You have to insert quotes in data with backslash quote. LMK if you need any help.

          ```
          > db.artists.insert({ "name" : "Quoted Andy Warhol", "genome" :

          { "\"Pop Art\"" : 10 }

          })
          Cannot use 'commands' readMode, degrading to 'legacy' mode
          WriteResult(

          { "nInserted" : 1 }

          )
          ```

          Show
          dblock Daniel Doubrovkine added a comment - - edited The above didn't quite render right. You have to insert quotes in data with backslash quote. LMK if you need any help. ``` > db.artists.insert({ "name" : "Quoted Andy Warhol", "genome" : { "\"Pop Art\"" : 10 } }) Cannot use 'commands' readMode, degrading to 'legacy' mode WriteResult( { "nInserted" : 1 } ) ```
          Hide
          dblock Daniel Doubrovkine added a comment -

          I am not sure why that commands error is there either, but I am going to ignore that for now.

          Show
          dblock Daniel Doubrovkine added a comment - I am not sure why that commands error is there either, but I am going to ignore that for now.
          Hide
          dblock Daniel Doubrovkine added a comment - - edited

          We're going to try to use 2.6.x mongoexport/mongoimport with 3.2.0 for now, which "seems" to work. Please do tell us if that workaround is a bad idea!

          Show
          dblock Daniel Doubrovkine added a comment - - edited We're going to try to use 2.6.x mongoexport/mongoimport with 3.2.0 for now, which "seems" to work. Please do tell us if that workaround is a bad idea!
          Hide
          gabriel.russell Gabriel Russell added a comment -

          Daniel,

          That quoting issue does appear to be a bug. We'll get on fixing it shortly.

          As for exporting with 2.6, there are several improvements in 3.0/3.2 in mongoexport around round-tripping of some datatypes. If you have mostly simple datatypes then 2.6 mongoexport should be fine.

          Gabriel

          Show
          gabriel.russell Gabriel Russell added a comment - Daniel, That quoting issue does appear to be a bug. We'll get on fixing it shortly. As for exporting with 2.6, there are several improvements in 3.0/3.2 in mongoexport around round-tripping of some datatypes. If you have mostly simple datatypes then 2.6 mongoexport should be fine. Gabriel
          Hide
          xgen-internal-githook Githook User added a comment -

          Author:

          {u'username': u'gabrielrussell', u'name': u'Gabriel Russell', u'email': u'gabriel.russell@mongodb.com'}

          Message: TOOLS-1039 marshal the keys of MarshalD
          Branch: master
          https://github.com/mongodb/mongo-tools/commit/314837d4ce1f8f800208e2a4af3bc6b422e492b5

          Show
          xgen-internal-githook Githook User added a comment - Author: {u'username': u'gabrielrussell', u'name': u'Gabriel Russell', u'email': u'gabriel.russell@mongodb.com'} Message: TOOLS-1039 marshal the keys of MarshalD Branch: master https://github.com/mongodb/mongo-tools/commit/314837d4ce1f8f800208e2a4af3bc6b422e492b5
          Hide
          xgen-internal-githook Githook User added a comment -

          Author:

          {u'username': u'gabrielrussell', u'name': u'Gabriel Russell', u'email': u'gabriel.russell@mongodb.com'}

          Message: TOOLS-1039 tests that MarshalD escapes keys correctly
          Branch: master
          https://github.com/mongodb/mongo-tools/commit/0d0f4abb4b403bbefe12a250cdb57c1267821835

          Show
          xgen-internal-githook Githook User added a comment - Author: {u'username': u'gabrielrussell', u'name': u'Gabriel Russell', u'email': u'gabriel.russell@mongodb.com'} Message: TOOLS-1039 tests that MarshalD escapes keys correctly Branch: master https://github.com/mongodb/mongo-tools/commit/0d0f4abb4b403bbefe12a250cdb57c1267821835

            People

            • Assignee:
              gabriel.russell Gabriel Russell
              Reporter:
              dblock Daniel Doubrovkine
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                  Agile