-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: 1.25.0
-
Component/s: Import/Export
-
Environment:OS:
node.js / npm versions:
Additional info:
-
Not Needed
Problem Description
When trying to export collections containing sub-documents, from Compass in CSV format, the fields from the sub-documents get exported as individual fields, rather than showing up under the sub-document field. I tested this with latest Compass Version 1.25.0.
This behavior is not observed when exporting to CSV via mongorestore.
Please refer to the reproducer steps below that explains this in detail.
Steps to Reproduce
Reproducer:
1. Inserted a collection with dictionaries and arrays like this:
replset:PRIMARY> db.dictionary_test1.find().pretty() { "_id" : 1, "dict1" : [ { "field11" : 111, "sub_dict1" : { "field11_1" : "AAAA" } } ], "dict2" : { "field222" : 222, "sub_dict2" : { "field22_2" : "BBB" } } }
2. Exported the collection in CSV format from Compass > Collection > Export Collection.
3. Opened the Compass-exported CSV in Excel, which shows as follows:
We observe that the sub-fields from dict2, specifically dict2.field222 and dict2.sub_dict2.field22_2, have been moved to separate columns. This happens with both "Export Full Collection" as well as with the "Export query with filters option" in Compass > Collection > Export Collection.
4. Exported the collection in CSV format using mongoexport, as follows:
mongoexport --port 39900 --db test --collection dictionary_test1 --fields _id,dict1,dict2 --type=csv --out mongoexp1.csv
5. Opened the mongoexport-exported CSV in Excel, which shows as follows:
We observe that the field dict2 and its sub-fields show correctly in the same column.
Expected Results
The sub-document field dict2 should show correctly in the exported output, as seen in the output generated by mongoexport.
Actual Results
The fields from the sub-documents, specifically dict2.field222 and dict2.sub_dict2.field22_2, get exported as individual fields, rather than showing up under field dict2.
- depends on
-
COMPASS-6425 importCSV() import function and tests
- Closed
-
COMPASS-6519 Switch to using importCSV()
- Closed
-
COMPASS-6520 Switch to using importJSON()
- Closed
-
COMPASS-6582 Remove new export feature flag, remove old export store an ui code
- Closed