-
Notifications
You must be signed in to change notification settings - Fork 411
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
Add SQL dialect for DB2 for IBM i #658
Merged
nene
merged 6 commits into
sql-formatter-org:master
from
chrjorgensen:feature/add-db2-for-i-dialect
Nov 9, 2023
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cb83ef6
Add SQL dialect for DB2 for IBM i
chrjorgensen c5feee5
Fix DB2 for IBM i formatter errors
chrjorgensen 7540fbf
Combine common db2i oneline clauses
chrjorgensen d0c9daf
Add replace and exists options to db2i tests
chrjorgensen 6802136
db2i supports 'using' on joins
chrjorgensen dd91db1
Fix join tests - 'id' is a reserved word in db2i
chrjorgensen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is it really the case that unquoted
id
can't be used as a column name in DB2 i?When I look at the reserved word lists of LUW-version and Z-version the
ID
indeed doesn't appear in reserved words list.However I still find it surprising that a) one would need to quote such a commonly used column name b) there's such a striking difference between the i-version of DB2 from other DB2 dialects.
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.
The reserved words list for DB2 for IBM i shows
ID
as a reserved word - but I haven't tested ifID
is allowed in the context of a column name.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 stumbled into the
ID
problem when I activatedJOIN ... USING
- suddenly the tests failed for DB2i becauseID
was converted to uppercase by the formatter. So I changed theid
in the test to a more generic column name.Just tested
id
ad a column name on DB2 for i - and it is indeed allowed... Is it better to removeID
from the reserved words list?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.
Could you please test this?
I remember seeing
ID
in the keywords list of some other SQL dialects, but it has always turned out that it's not really a reserved keyword.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.
Yep. Best to just remove it from reserved words list. Given that this list has currently like 500 words, my suspicion is that many more of these keywords are actually not reserved.
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 encountered a similar problem when trying to find out which keywords does SingleStoreDB actually reserve. Their documentation only listed all the keywords and didn't distinguish which ones are reserved and which ones were not. I ended up executing hundreds of SQL queries to see which would actually result in a failure.