Skip to content

Commit cf0d74f

Browse files
Fixes #1325 (#1327)
Removes redundant production Identifier() and uses RelObjectnameWithoutValue() instead for MS SQL Server Hints
1 parent d18c59b commit cf0d74f

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,31 +2084,27 @@ MySQLIndexHint MySQLIndexHint():
20842084
List<String> indexNameList = new ArrayList<String>();
20852085
}
20862086
{
2087-
(actionToken = <K_USE>
2087+
(
2088+
actionToken = <K_USE>
20882089
| actionToken = <K_SHOW>
20892090
| actionToken = <K_IGNORE>
2090-
| actionToken = <K_FORCE> )
2091-
(indexToken = <K_INDEX>
2092-
| indexToken = <K_KEY>)
2091+
| actionToken = <K_FORCE>
2092+
)
2093+
2094+
(
2095+
indexToken = <K_INDEX>
2096+
| indexToken = <K_KEY>
2097+
)
2098+
20932099
"("
2094-
indexName = Identifier() { indexNameList.add(indexName); }
2095-
("," indexName= Identifier() { indexNameList.add(indexName); })*
2100+
indexName = RelObjectNameWithoutValue() { indexNameList.add(indexName); }
2101+
("," indexName= RelObjectNameWithoutValue() { indexNameList.add(indexName); })*
20962102
")"
20972103
{
20982104
return new MySQLIndexHint(actionToken.image, indexToken.image, indexNameList);
20992105
}
21002106
}
21012107

2102-
String Identifier():
2103-
{
2104-
Token tk = null;
2105-
}
2106-
{
2107-
(tk=<S_IDENTIFIER>
2108-
| tk=<S_QUOTED_IDENTIFIER>)
2109-
{ return tk.image; }
2110-
}
2111-
21122108
FunctionItem FunctionItem():
21132109
{
21142110
Alias alias = null;

src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4805,4 +4805,11 @@ public void testGroupByComplexExpressionIssue1308() throws JSQLParserException {
48054805
"from dual \n" +
48064806
"group by (case when 1=1 then 'X' else 'Y' end), column1", true);
48074807
}
4808+
4809+
@Test
4810+
public void testReservedKeywordsMSSQLUseIndexIssue1325() throws JSQLParserException {
4811+
// without extra brackets
4812+
assertSqlCanBeParsedAndDeparsed(
4813+
"SELECT col FROM table USE INDEX(primary)", true);
4814+
}
48084815
}

0 commit comments

Comments
 (0)