Skip to content

Fixes #1325 #1327

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

Merged
merged 1 commit into from
Sep 6, 2021
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
28 changes: 12 additions & 16 deletions src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -2084,31 +2084,27 @@ MySQLIndexHint MySQLIndexHint():
List<String> indexNameList = new ArrayList<String>();
}
{
(actionToken = <K_USE>
(
actionToken = <K_USE>
| actionToken = <K_SHOW>
| actionToken = <K_IGNORE>
| actionToken = <K_FORCE> )
(indexToken = <K_INDEX>
| indexToken = <K_KEY>)
| actionToken = <K_FORCE>
)

(
indexToken = <K_INDEX>
| indexToken = <K_KEY>
)

"("
indexName = Identifier() { indexNameList.add(indexName); }
("," indexName= Identifier() { indexNameList.add(indexName); })*
indexName = RelObjectNameWithoutValue() { indexNameList.add(indexName); }
("," indexName= RelObjectNameWithoutValue() { indexNameList.add(indexName); })*
")"
{
return new MySQLIndexHint(actionToken.image, indexToken.image, indexNameList);
}
}

String Identifier():
{
Token tk = null;
}
{
(tk=<S_IDENTIFIER>
| tk=<S_QUOTED_IDENTIFIER>)
{ return tk.image; }
}

FunctionItem FunctionItem():
{
Alias alias = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4776,4 +4776,11 @@ public void testGroupByComplexExpressionIssue1308() throws JSQLParserException {
"from dual \n" +
"group by (case when 1=1 then 'X' else 'Y' end), column1", true);
}

@Test
public void testReservedKeywordsMSSQLUseIndexIssue1325() throws JSQLParserException {
// without extra brackets
assertSqlCanBeParsedAndDeparsed(
"SELECT col FROM table USE INDEX(primary)", true);
}
}