Fix CSV and JSON export to handle null values correctly #20037
+263
−25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When exporting query results to CSV format, null values were being saved as the literal string "null" instead of blank cells. This behavior was inconsistent with Excel export functionality, where null values correctly appear as empty cells.
Problem
The issue occurred in the
constructCsvString
andconstructJsonString
methods inqueryRunner.ts
. Both methods were using thedisplayValue
property directly without checking theisNull
flag ofDbCellValue
objects. When a database column contained a null value, thedisplayValue
would contain the string "null", which was then exported literally.Solution
Modified both export methods to check the
isNull
property first:CSV Export:
JSON Export:
Testing
Added comprehensive test cases for both CSV and JSON exports that verify:
"1,,3"
instead of"1,null,3"
)"null"
strings)Impact
This change makes the CSV export behavior consistent with Excel export, where null database values appear as blank cells. The fix is minimal and surgical, only affecting the specific null value handling while preserving all existing functionality for non-null values.
Fixes #18528.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
update.code.visualstudio.com
node ./out/test/unit/runTest.js
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.