Provide the Bytebase version you are using
3.19.1
Describe the bug
When exporting a MongoDB query result from the SQL Editor, the generated CSV, XLSX, and JSON files contain only one column named result.
Each cell in that column contains the entire MongoDB document as a Relaxed Extended JSON string.
For example, the CSV output currently looks similar to this:
result
"{""_id"":1129063441,""device_id"":""abc"",""user_id"":""123"",""device_model"":""iPhone""}"
The SQL Editor table view already displays the same result as separate columns, such as:
_id
device_id
user_id
device_model
user_agent
user_ip
The exported file should follow the same flattened structure as the table view.
This affects CSV, XLSX, and JSON exports.
Steps to reproduce
Connect Bytebase to a MongoDB database.
Open the SQL Editor.
Run a query that returns MongoDB documents, for example:
db.devices.find({})
Confirm that the SQL Editor table view displays each document field as a separate column.
Export the result as CSV.
Export the same result as XLSX.
Export the same result as JSON.
Open the exported files.
Observe that the result contains a single result column and each row contains the whole MongoDB document as a JSON string.
Expected behavior
MongoDB query result exports should use the same flattened columns shown in the SQL Editor table view.
For CSV, the output should contain a header row and one field per column:
_id,device_id,user_id,device_model,user_agent,user_ip
1129063441,abc,123,iPhone,Mozilla/5.0,10.0.0.1
For XLSX, the first row should contain the field names and each value should be written to a separate cell.
For JSON, the result should be exported as an array of objects:
[
{
"_id": 1129063441,
"device_id": "abc",
"user_id": "123",
"device_model": "iPhone",
"user_agent": "Mozilla/5.0",
"user_ip": "10.0.0.1"
}
]
It should not be exported as an object containing a JSON document inside the result field:
[
{
"result": "{"_id":1129063441,"device_id":"abc"}"
}
]
Missing fields should be exported as empty or null cells depending on the export format.
Nested MongoDB documents and arrays can remain as compact JSON values inside a single cell, matching how they are displayed in the SQL Editor table.
Provide the database you are using
Mongodb 7.x and 8.x
Additional context
The MongoDB backend currently returns query results as a single column named result. Each row contains one Relaxed Extended JSON document.
The SQL Editor applies MongoDB result flattening only in the frontend for the table view. The export flow runs the query again on the backend and sends the original single-column result directly to the shared CSV, XLSX, and JSON writers.
Provide the Bytebase version you are using
3.19.1
Describe the bug
When exporting a MongoDB query result from the SQL Editor, the generated CSV, XLSX, and JSON files contain only one column named result.
Each cell in that column contains the entire MongoDB document as a Relaxed Extended JSON string.
For example, the CSV output currently looks similar to this:
result
"{""_id"":1129063441,""device_id"":""abc"",""user_id"":""123"",""device_model"":""iPhone""}"
The SQL Editor table view already displays the same result as separate columns, such as:
_id
device_id
user_id
device_model
user_agent
user_ip
The exported file should follow the same flattened structure as the table view.
This affects CSV, XLSX, and JSON exports.
Steps to reproduce
Connect Bytebase to a MongoDB database.
Open the SQL Editor.
Run a query that returns MongoDB documents, for example:
db.devices.find({})
Confirm that the SQL Editor table view displays each document field as a separate column.
Export the result as CSV.
Export the same result as XLSX.
Export the same result as JSON.
Open the exported files.
Observe that the result contains a single result column and each row contains the whole MongoDB document as a JSON string.
Expected behavior
MongoDB query result exports should use the same flattened columns shown in the SQL Editor table view.
For CSV, the output should contain a header row and one field per column:
_id,device_id,user_id,device_model,user_agent,user_ip
1129063441,abc,123,iPhone,Mozilla/5.0,10.0.0.1
For XLSX, the first row should contain the field names and each value should be written to a separate cell.
For JSON, the result should be exported as an array of objects:
[
{
"_id": 1129063441,
"device_id": "abc",
"user_id": "123",
"device_model": "iPhone",
"user_agent": "Mozilla/5.0",
"user_ip": "10.0.0.1"
}
]
It should not be exported as an object containing a JSON document inside the result field:
[
{
"result": "{"_id":1129063441,"device_id":"abc"}"
}
]
Missing fields should be exported as empty or null cells depending on the export format.
Nested MongoDB documents and arrays can remain as compact JSON values inside a single cell, matching how they are displayed in the SQL Editor table.
Provide the database you are using
Mongodb 7.x and 8.x
Additional context
The MongoDB backend currently returns query results as a single column named result. Each row contains one Relaxed Extended JSON document.
The SQL Editor applies MongoDB result flattening only in the frontend for the table view. The export flow runs the query again on the backend and sends the original single-column result directly to the shared CSV, XLSX, and JSON writers.