vscode-ibmi
vscode-ibmi copied to clipboard
`runSQL` API supporting comments at end of line
Looks like QSYS/QZDFMDB2
is ignoring comments at the end of lines and thinks the rest of the script is a comment, but it does work when the line starts with a comment.
Not working
select *
from sample.employee --my table
limit 1
Working
select *
--my table
from sample.employee
limit 1
Manual intervention is required.
From @m-tyler.
Describe the bug I use inline SQL comments A LOT. I use it to deactivate sections of the query, like removing a result column, removing a join line, insert CTE test lines, etc. However, it appears the parser for Code for IBM i does not correctly recognize these comments.
Inline comments are two dashes and a space. It's the default comment for VS Code SQL language type shortcut Ctrl+/.I noticed today that one of my CTE test lines (a line that ends with a semi colon but is in the commented state) will cause the statement to be parsed only to that point.
To Reproduce Run this query.
with t1 as (select SYSTEM_TABLE_SCHEMA ,SYSTEM_TABLE_NAME ,SYSTEM_TABLE_MEMBER from QSYS2.SYSPARTITIONSTAT) -- select * from T1 where TABLE_SCHEMA = 'D1WFIQUAL' and TABLE_NAME like 'KRNMDA%'; select * from T1 where TABLE_SCHEMA = 'D1WFIQUAL' and TABLE_NAME like 'KRNMDA%';
Expected behavior I expect comments to be excluded from the run query but I understand that is a bit harder than it sounds.
Environment (please complete the following information):
- Extension version 1.2.6
- IBM i OS version 7.3
From what I am seeing the statement "... but it does work when the line starts with a comment." needs to be modified to say "but it does work when the line starts with a comment in position 1"
This is unfortunate as the Generate SQL option often includes generated comments that are indented. For example:
-- Generate SQL
-- Version: V7R4M0 190621
-- Generated on: 09/06/22 09:17:43
-- Relational Database: IDEVELOP
-- Standards Option: Db2 for i
CREATE
OR REPLACE TABLE PARTNER400.CUSTOMERS (
-- SQL150B 10 REUSEDLT(*NO) in table CUSTOMERS in PARTNER400 ignored.
-- SQL1506 30 Key or attribute for CUSTOMERS in PARTNER400 ignored.
-- SQL1505 20 Number of members for CUSTOMERS in PARTNER400 not valid.
CUSTNO CHAR(5) CCSID 37 NOT NULL DEFAULT '',
NAME CHAR(30) CCSID 37 NOT NULL DEFAULT '',
CITY CHAR(24) CCSID 37 NOT NULL DEFAULT '',
STATE CHAR(2) CCSID 37 NOT NULL DEFAULT '',
ZIP NUMERIC(5, 0) NOT NULL DEFAULT 0,
ZIPPLUS NUMERIC(4, 0) NOT NULL DEFAULT 0
) RCDFMT CUSTREC;
If you try to run this generated statement it will error out at the first indented comment line.