Skip to content
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

Allow isolation keywords as column name and aliases #1534

Merged
merged 1 commit into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ String RelObjectNameWithoutValue() :
| tk=<K_ARRAY_LITERAL>
| tk=<K_STRING_FUNCTION_NAME>
| tk=<K_USER>
| tk=<K_RECYCLEBIN> | tk=<K_DBA_RECYCLEBIN>
| tk=<K_RECYCLEBIN> | tk=<K_DBA_RECYCLEBIN> | tk=<K_ISOLATION>

/* Keywords for ALTER SESSION */
/* | tk=<K_NAME> */ | tk=<K_TIMEOUT> | tk=<K_PARALLEL>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2500,6 +2500,12 @@ public void testMultiValueIn4() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed(stmt);
}

@Test
public void selectIsolationKeywordsAsAlias() throws JSQLParserException {
String stmt = "SELECT col FROM tbl cs";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not test your isolation usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other tests already testing isolation usage (for example, testWithIsolation).
This PR just allows "cs" to be used as a column name / alias, as otherwise parsing fails when it's used.

assertSqlCanBeParsedAndDeparsed(stmt);
}

@Test
public void testMultiValueInBinds() throws JSQLParserException {
String stmt = "SELECT * FROM mytable WHERE (a, b) IN ((?, ?), (?, ?))";
Expand Down