Skip to content

Feature/csv header source - #601

Merged
buzzia2001 merged 4 commits into
codefori:mainfrom
benetti-marco:feature/csv-header-source
Nov 25, 2026
Merged

buzzia2001 merged 4 commits into
codefori:mainfrom
benetti-marco:feature/csv-header-source

Conversation

@benetti-marco

Copy link
Copy Markdown
Contributor

Add setting to choose CSV header source (column name or label)

When a result set is exported as CSV (csv: prefix), the header row always contains the column names. This PR adds a setting to use the column labels (headings) instead.

Changes

  • New setting vscode-db2i.codegen.csvHeaderSource (under Code generation):
    • Name (default): uses the column name, same as the current behaviour
    • Label: uses the column label
  • The header row in src/views/results/index.ts uses the setting. If a column has an empty label, its name is used instead, so no header is ever blank.
  • Labels are normalized: blanks inside them are collapsed to a single space and leading/trailing blanks are trimmed (column headings can be up to 3 segments of 20 characters, padded with blanks).
  • Data rows are still read by column name, so duplicate column names work as before.

Notes

  • Labels are only returned when Extended metadata is enabled in the JDBC configuration (same requirement as rpgSymbolicNameSource). The setting description says so.
  • If a column has no heading (no LABEL ON COLUMN), the system returns the column name as its label, so the header shows the name.
  • If the result set has no column metadata, the CSV is built with csv.stringify. In that case the header row still uses column names, because labels aren't available there. A comment in the code explains this.

How to test

  1. Enable Extended metadata in the JDBC configuration.
  2. Set Code generation › Csv Header Source to Label.
  3. Run csv: select * from <table with column headings> and check that the header row contains the labels.
  4. Optionally add a multi-segment heading to check the blank normalization:
    label on column <lib>.<table> (<col> is 'Customer Code');
    The header should show "Customer Code".
  5. Set it back to Name and check that the output is unchanged from before.

@SanjulaGanepola

Copy link
Copy Markdown
Member

@benetti-marco There was some refactoring done in #595 which caused some conflicts with this PR. Can you update this PR accordingly?

@benetti-marco

Copy link
Copy Markdown
Contributor Author

Sure. I'll do it next week.

@benetti-marco

Copy link
Copy Markdown
Contributor Author

@benetti-marco There was some refactoring done in #595 which caused some conflicts with this PR. Can you update this PR accordingly?

done!

@buzzia2001 buzzia2001 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.

Works fine, thank you

@buzzia2001
buzzia2001 merged commit 182af63 into codefori:main Nov 25, 2026
1 check passed
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