Skip to content

Handle scalar rows in CSV export - #224

Open
Mike Krüger (mkrueger) wants to merge 1 commit into
mainfrom
dev/mkrueger/fix-csv-export-scalars
Open

Mike Krüger (mkrueger) wants to merge 1 commit into
mainfrom
dev/mkrueger/fix-csv-export-scalars

Conversation

@mkrueger

Copy link
Copy Markdown
Collaborator

Problem

export --format=csv collected CSV headers only from JSON object properties. Rows whose value is not an object (for example export out.csv --format=csv --query="SELECT VALUE c.id FROM c", or numbers, booleans, null, arrays) were written as empty lines, while the command still reported the exported row count.

Change

  • Non-object rows are written to a value column, matching the existing scalar CSV rendering in CommandState.Table.cs (JsonElement.ToString() escaped with CommandState.EscapeCSV).
  • Mixed result sets keep both the object property columns and the value column, so no row loses data.
  • Object-only exports are unchanged.
  • docs/commands.md describes the value column and the mixed case.

Tests in ExportCommandTests cover scalar strings that need escaping, numbers, booleans, null, arrays, object-only rows, and mixed rows.

Add a value column for non-object CSV export rows so scalar and mixed query results keep their data while preserving existing object row behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The targeted implementation matches existing rendering behavior and is adequately documented and tested.

Review effort: Balanced
Findings: None

What changed in this PR

Adds CSV export support for scalar and mixed query results.

Changes:

  • Writes non-object rows to a value column.
  • Preserves object-only behavior and supports mixed rows.
  • Adds documentation and comprehensive tests.
File Description
docs/​commands.md Documents scalar and mixed CSV output.
ExportCommand.cs Adds scalar-value column generation.
ExportCommandTests.cs Covers scalar, object, array, and mixed rows.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall line coverage in commit 0879cf2 in the dev/mkrueger/fix-csv... branch remains at 64%, unchanged from commit 345ddb8 in the main branch.

Show a line coverage summary of the most impacted files.
File main 345ddb8 dev/mkrueger/fix-csv... 0879cf2 +/-
D:\a\CosmosDBSh...xportCommand.cs 62% 64% +2%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants