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

mongoexport won't export nulls to CSV

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: mongoexport
    • None

      If a document's value for field "foo" is null, and "foo" is in the field list for mongoexport --csv, mongoexport refuses to export that document. The error message is, "Invalid BSON object type for CSV output: 10." Better if mongoexport wrote an empty string or the string "null" instead.

      Steps to reproduce:

      In mongo shell:

      > db.nullcsv.insert({"a":null})
      

      Running mongoexport:

      $ ./mongoexport --csv -c nullcsv -d test --fields "a"
      connected to: 127.0.0.1
      a
      Invalid BSON object type for CSV output: 10
      
      exported 1 records
      

      The same thing happens with deprecated BSON types "DBPointer" and "undefined".

      It's unclear what the appropriate action here should be, but a small improvement may just be to improve the error messages to explain better why the failure is happening.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: