Skip to content

Conversation

@davecharron
Copy link
Collaborator

@davecharron davecharron commented Mar 26, 2024

Overview

Add support for customizing result column headings.

  • New configuration setting for Column headings
    • Options are Name and Label
      Note: Label requires the JDBC config 'Extended metadata' setting to be turned on.
  • New command for editing the setting from the results view
  • Listen for changes to the setting and apply to open results view
  • Bonus: Organized the Db2 for i preferences

Test

CREATE SCHEMA TESTHEAD;

CREATE OR REPLACE TABLE TESTHEAD.T1 (
            C1 INTEGER DEFAULT NULL,
            C2 VARCHAR(25) CCSID 37 DEFAULT NULL
        );

LABEL ON COLUMN TESTHEAD.T1 (
    C1 IS 'C1 Column Heading',
    C2 IS 'C2 Column Heading'
);

SELECT * FROM TESTHEAD.T1

Closes #127 Ability to toggle file column labels on results view

@davecharron davecharron added enhancement New feature or request ready The tag should be taken off if it is being worked on, or if a review fails labels Mar 26, 2024
@davecharron davecharron requested a review from worksofliam March 26, 2024 22:56
@davecharron davecharron self-assigned this Mar 26, 2024
@worksofliam
Copy link
Member

@davecharron Send help! What am I doing wrong to test this? Sorry for the big screenshot, but it shows:

  • My select statement, with a LABEL statement to update the label of a column.
  • I have 'Label' selected in my VS Code settings
  • I have Extended metadata to true and saved

But can't get it to show up.

image

Through a little more digging, it looks like the server component isn't returning is still?

"columns":[{"name":"EMPNO","type":"CHAR","display_size":6,"label":"EMPNO"},

@davecharron
Copy link
Collaborator Author

davecharron commented Mar 27, 2024

Send help! What am I doing wrong to test this? Sorry for the big screenshot, but it shows:

You might try adding the TEXT keyword to the LABEL ON statement. It switches between setting column heading and label.

LABEL ON COLUMN SAMPLE.employee (EMPNO TEXT IS 'Employee Number');

https://www.ibm.com/docs/en/i/7.5?topic=statements-label

COLUMN
Specifies that the label is for a column. Labels on columns are implemented as system column headings or column text. Column headings are used when displaying or printing query results.

table-name.column-name or view-name.column-name
    Identifies the column to which the label applies. The table-name or view-name must identify a table or view that exists at the current server, but must not identify a declared temporary table. The column-name must identify a column of that table or view.

TEXT
Specifies that IBM® i column text is specified. If TEXT is omitted, a column heading is specified.

It's possible that you might need to reconnect after the LABEL ON. We've seen issues where SQ caches metadata so it doesn't always show recent changes.

@worksofliam
Copy link
Member

Okay, I got it working. It did require a new job to get the changes. This worked:

select * from sample.employee;

LABEL ON COLUMN SAMPLE.employee (EMPNO IS 'Employee Number');

More comments coming.

@worksofliam
Copy link
Member

@davecharron So based on this PR, I think we should change one of the JDBCOptions default.

Perhaps, in the SQLJob constructor, where we pass JDBCOptions as options, we should set extended metadata on by default for all jobs?

  constructor(public options: JDBCOptions = {}) {
    this.options["extended metadata"] = true;
  }

@davecharron
Copy link
Collaborator Author

davecharron commented Apr 1, 2024

@worksofliam I'm not sure about changing the default.

The Javadoc for JDBC Properties indicates a potential performance hit when "extended metadata" is set to true.

Setting this property to true may slow performance because it requires retrieving more information from the system.

@worksofliam
Copy link
Member

@davecharron Plus, users can store it in their custom config if they want it enabled always. Good point.

@davecharron davecharron requested a review from worksofliam April 4, 2024 21:13
@davecharron davecharron merged commit dfc9550 into codefori:main Apr 8, 2024
@davecharron davecharron deleted the feature/result_table_column_headings branch April 16, 2024 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ready The tag should be taken off if it is being worked on, or if a review fails

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to toggle file column labels on results view

2 participants