Skip to content

Commit c126e1e

Browse files
committed
support for some keywords as objectnames
1 parent 3aabff2 commit c126e1e

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/main/javacc/net/sf/jsqlparser/parser/JSqlParserCC.jj

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* #%L
33
* JSQLParser library
44
* %%
5-
* Copyright (C) 2004 - 2013 JSQLParser
5+
* Copyright (C) 2004 - 2014 JSQLParser
66
* %%
77
* This program is free software: you can redistribute it and/or modify
88
* it under the terms of the GNU Lesser General Public License as
@@ -35,7 +35,7 @@ PARSER_BEGIN(CCJSqlParser)
3535
* #%L
3636
* JSQLParser library
3737
* %%
38-
* Copyright (C) 2004 - 2013 JSQLParser
38+
* Copyright (C) 2004 - 2014 JSQLParser
3939
* %%
4040
* This program is free software: you can redistribute it and/or modify
4141
* it under the terms of the GNU Lesser General Public License as
@@ -455,11 +455,8 @@ Column Column():
455455
String RelObjectName():
456456
{ Token tk = null; }
457457
{
458-
(
459-
tk=<S_IDENTIFIER>
460-
|
461-
tk=<S_QUOTED_IDENTIFIER>
462-
)
458+
(tk=<S_IDENTIFIER> | tk=<S_QUOTED_IDENTIFIER>
459+
| tk=<K_CAST> | tk=<K_DO> | tk=<K_EXTRACT> | tk=<K_FIRST> | tk=<K_FOLLOWING> | tk=<K_LAST> | tk=<K_MATERIALIZED> | tk=<K_NULLS> | tk=<K_PARTITION> | tk=<K_RANGE> | tk=<K_ROW> | tk=<K_ROWS> | tk=<K_SIBLINGS> | tk=<K_VALUE> | tk=<K_XML>)
463460

464461
{ return tk.image; }
465462
}
@@ -660,18 +657,16 @@ SelectExpressionItem SelectExpressionItem():
660657
SelectItem SelectItem():
661658
{
662659
SelectItem selectItem = null;
663-
SelectExpressionItem selectExpressionItem = null;
664660
}
665661
{ ("*" { selectItem = new AllColumns(); }
666662
|
667663
LOOKAHEAD(AllTableColumns()) selectItem=AllTableColumns()
668664
|
669-
selectExpressionItem=SelectExpressionItem() {selectItem = selectExpressionItem; }
665+
LOOKAHEAD(SelectExpressionItem()) selectItem=SelectExpressionItem()
670666
)
671667
{
672668
return selectItem;
673669
}
674-
675670
}
676671

677672
AllTableColumns AllTableColumns():

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,12 @@ public void testPostgreSQLRegExpCaseSensitiveMatch4() throws JSQLParserException
14151415
assertSqlCanBeParsedAndDeparsed(stmt);
14161416
}
14171417

1418+
public void testReservedKeyword() throws JSQLParserException {
1419+
final String statement = "SELECT cast, do, extract, first, following, last, materialized, nulls, partition, range, row, rows, siblings, value, xml FROM tableName"; // all of these are legal in SQL server; 'row' and 'rows' are not legal on Oracle, though;
1420+
final Select select = (Select) parserManager.parse(new StringReader(statement));
1421+
assertStatementCanBeDeparsedAs(select, statement);
1422+
}
1423+
14181424
public void testCharacterSetClause() throws JSQLParserException {
14191425
String stmt="SELECT DISTINCT CAST(`view0`.`nick2` AS CHAR (8000) CHARACTER SET utf8) AS `v0` FROM people `view0` WHERE `view0`.`nick2` IS NOT NULL";
14201426
assertSqlCanBeParsedAndDeparsed(stmt);

0 commit comments

Comments
 (0)