-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API change: use default CCSID to run SQL queries when needed #1828
Conversation
Signed-off-by: Seb Julliand <sebjulliand@gmail.com>
Signed-off-by: Seb Julliand <sebjulliand@gmail.com>
Avoid CCSID 1200 to 65535 conversion error Signed-off-by: Seb Julliand <sebjulliand@gmail.com>
Signed-off-by: Seb Julliand <sjulliand@arcadsoftware.com>
Signed-off-by: Seb Julliand <sjulliand@arcadsoftware.com>
Signed-off-by: Seb Julliand <sjulliand@arcadsoftware.com>
…poses) Signed-off-by: Seb Julliand <sjulliand@arcadsoftware.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requested some changes, simple stuff mostly.
I would also appreciate an additional test for runSQL
that includes running a CL command and then a statement.
Perhaps something like CHGLIBL
and then select * from QSYS2. LIBRARY_LIST_INFO
.
Signed-off-by: Seb Julliand <sjulliand@arcadsoftware.com>
Signed-off-by: Seb Julliand <sjulliand@arcadsoftware.com>
Thanks @worksofliam ! |
Signed-off-by: Seb Julliand <sjulliand@arcadsoftware.com>
name: `Test @clCommand + select statement`, test: async () => { | ||
const content = instance.getContent()!; | ||
|
||
const [result] = await content.runSQL(`@CRTSAVF FILE(QTEMP/UNITTEST) TEXT('Code for i test');\nSelect * From Table(QSYS2.OBJECT_STATISTICS('QTEMP', '*FILE')) Where OBJATTRIBUTE = 'SAVF';`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great test case!
@sebjulliand Before I leave my final review, I do think as part of this, before we release it especially, is that we should document this at a high level on our CCSID page. Something like... yep, we're setting the CCSID, but you really should set it on your user profile. |
@worksofliam agreed, and maybe add a button to open the URL on the notification that says naught-no-ccsid. |
@sebjulliand Is that something you want to include in this PR or another time? |
@@ -50,7 +50,8 @@ export default class IBMi { | |||
defaultUserLibraries: string[]; | |||
outputChannel?: vscode.OutputChannel; | |||
aspInfo: { [id: number]: string }; | |||
qccsid: number | null; | |||
qccsid: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am starting to wonder if this qccsid
property should be renamed. Years ago we used to only check for QCCSID
, but now we also store the job CCSID in this first.
What do you think?
Thanks @worksofliam ! I'll merge now, and open another PR for renaming |
Changes
Running SQL queries in a job whose CCSID is 65535 is bad. This PR tries to avoid conversion errors by running a
CHGJOB CCSID(xx)
command before every SQL statement run throughQZDFMDB2
.In above command,
xx
is the job's default CCSID which is retrieved at connection time (once then cached).Noticeable changes:
ACTIVE_JOB
SQL service. If it fails, we fall back to usingDSPJOB OPTION(*DFNA)
and parsing the output.runSQL
method has been simplified a bit. The logic to sanitize the statement about to be run has been put in a separate method inTools
and there is a unit test to check it.QZDFMDB2
allows to run CL command simply by prefixing them with@
. It's convenient but it turns out such statements are always run in a separate job. So the method that sanitizesQZDFMDB2
statements will also rewrite every@command
intoCall QSYS2.QCMDEXC('command')
.getMemberList
function to avoid a 1200 -> 65535 conversion issue, apparently unavoidable even withCHGJOB
. The member's TEXT field is using CCSID 1200.Report Issue
template. It is also reported in the Code for i output if QCCSID is bad.Checklist