Skip to content

feat: add configuration for CSV decimal separator and update CSV formatting logic - #594

Merged
SanjulaGanepola merged 2 commits into
codefori:mainfrom
benetti-marco:feature/csv-decimal-separator
Oct 26, 2026
Merged

SanjulaGanepola merged 2 commits into
codefori:mainfrom
benetti-marco:feature/csv-decimal-separator

Conversation

@benetti-marco

Copy link
Copy Markdown
Contributor

Changes

Adds a new setting, Csv Decimal Separator (vscode-db2i.codegen.csvDecimalSeparator), to control the decimal separator used for numeric values when exporting results with the csv: prefix.

  • Period (default): 1234.56, the current behaviour
  • Comma: 1234,56

This is useful in locales that use a comma as the decimal separator. For example, Excel with Italian regional settings reads 1234.56 as text instead of a number.

Implementation:

  • The setting is defined in src/views/results/contributes.json, next to csvColumnDelimiter. package.json was regenerated with vscd --clean.
  • In the metadata-based export, the separator is applied to DECIMAL, NUMERIC, DECFLOAT, DOUBLE, FLOAT and REAL columns, and to any value returned as a JS number.
  • In the fallback export that uses csv.stringify, the separator is applied through the library's cast.number option.
  • CSV values are always quoted, so Comma also works when the column delimiter is a comma. Semicolon is still the most convenient delimiter for Excel.

How to test this PR

  1. In the extension settings (Code generation), set Csv Decimal Separator to Comma and, optionally, Csv Column Delimiter to Semicolon.
  2. Run:
    csv: select 1.5 as a, cast(123.45 as decimal(7,2)) as b, 'x.y' as c from sysibm.sysdummy1
  3. Check that A and B use a comma ("1,5", "123,45") and that the string column C stays unchanged ("x.y").
  4. Set the setting back to Period and check that the output is the same as before.

Checklist

  • have tested my change
  • have created one or more test cases
  • updated relevant documentation
  • Remove any/all console.logs I added

Copilot AI balanced review requested due to automatic review settings October 24, 2026 12:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The configuration and formatting changes are focused and consistent, with no blocking issues identified.

No open issues 🎉

What changed in this PR

Adds configurable decimal separators to CSV exports, supporting locales that use commas while retaining periods as the default.

Changes:

  • Adds the Csv Decimal Separator setting with Period and Comma options.
  • Applies numeric formatting to both metadata-based exports and the fallback CSV serializer.
File Description
src/​views/​results/​index.ts Applies the selected decimal separator when formatting numeric CSV values.
src/​views/​results/​contributes.json Defines the decimal separator setting and its options.
package.json Registers the setting in the generated extension manifest.

Review effort: Balanced

@SanjulaGanepola
SanjulaGanepola self-requested a review October 26, 2026 19:29
Signed-off-by: Sanjula Ganepola <Sanjula.Ganepola@ibm.com>

@SanjulaGanepola SanjulaGanepola left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@benetti-marco Changes look good and it works as expected. Thanks

@SanjulaGanepola
SanjulaGanepola merged commit c172114 into codefori:main Oct 26, 2026
1 check passed
@benetti-marco
benetti-marco deleted the feature/csv-decimal-separator branch October 26, 2026 20:28
@benetti-marco
benetti-marco restored the feature/csv-decimal-separator branch October 26, 2026 20:28
@buzzia2001 buzzia2001 mentioned this pull request Oct 26, 2026
4 of 5 tasks
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.

3 participants