-
Notifications
You must be signed in to change notification settings - Fork 28
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
Fix linebreaks in generated SQL #326
Conversation
src/database/schemas.ts
Outdated
].join(` `), { parameters: [object, schema, internalType] }); | ||
const lines = await JobManager.runSQL<{ LINE: string }>( | ||
`select LINE | ||
from table( QSYS2.IFS_READ( PATH_NAME => '/tmp/Q_GENSQL_' concat current_user concat '.sql' ) )` |
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.
At this point, should we just use our own Code for IBM i API to get the contents of the file?
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.
We could... and we could also use our own C4i API to run the SQL and get the result in one step instead of these multiple calls. And maybe use the temporary streamfile API?
I'm quite busy currently with bigger projects at work, so we either
- wait for me to get some spare time
- let you code it or
- put a TODO in the source.
Which do you prefer? 😉
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 happy to do it actually! I will have a go at it on Monday morning. Using the temp streamfile is also a good idea.
Signed-off-by: worksofliam <[email protected]>
Signed-off-by: worksofliam <[email protected]>
The Generate SQL output use the result set from the
QSYS2.GENERATE_SQL
procedure, but this is using a source member (in QTEMP) as intermediate storage and thus have a fixed length source line - 80 characters by default.This is a problem, since identifiers can be split by a linebreak.
An example is the generated source for view
QSYS2.OBJECT_LOCK_INFO
where the lines containing the SELECT is broken in the middle of identifiers and functions:This can not be fixed by the SQL formatter, which will replace a linebreak in an identifier by a space:
This PR will change the use of the
QSYS2.GENERATE_SQL
procedure to generate a streamfile instead of a source member and read this file. This will eliminate the problem with linebreaks in identifiers:After SQL formatting the source will look as expected: