Skip to content

Commit

Permalink
fixes #122
Browse files Browse the repository at this point in the history
  • Loading branch information
wumpz committed Apr 9, 2015
1 parent 68f47dc commit 46f5197
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/main/javacc/net/sf/jsqlparser/parser/JSqlParserCC.jj
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,21 @@ String RelObjectName():
{ return tk.image; }
}

/*
Extended usage of object names.
*/
String RelObjectNameExt():
{ Token tk = null;
String result=null;
}
{
( result=RelObjectName() | tk=<K_LEFT> | tk=<K_RIGHT> )
{
if (tk!=null) result=tk.image;
return result;
}
}

Table Table():
{
String serverName = null, databaseName = null, schemaName = null, tableName = null;
Expand Down Expand Up @@ -2067,9 +2082,9 @@ Function Function():
{
["{fn" { retval.setEscaped(true); } ]

funcName=RelObjectName()
funcName=RelObjectNameExt()

[ "." tmp=RelObjectName() { funcName+= "." + tmp; } ["." tmp=RelObjectName() { funcName+= "." + tmp; }]]
[ "." tmp=RelObjectNameExt() { funcName+= "." + tmp; } ["." tmp=RelObjectNameExt() { funcName+= "." + tmp; }]]
"(" [ [<K_DISTINCT> { retval.setDistinct(true); } | <K_ALL> { retval.setAllColumns(true); }] (expressionList=SimpleExpressionList() | "*" { retval.setAllColumns(true); }) ] ")"

[ "." tmp=RelObjectName() { retval.setAttribute(tmp); }]
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/net/sf/jsqlparser/test/select/SelectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,16 @@ public void testAnalyticFunctionProblem1b() throws JSQLParserException {
String statement = "SELECT last_value(s.revenue_hold) OVER (PARTITION BY s.id_d_insertion_order, s.id_d_product_ad_attr, trunc(s.date_id, 'mm') ORDER BY s.date_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS col FROM s";
assertSqlCanBeParsedAndDeparsed(statement);
}

public void testFunctionLeft() throws JSQLParserException {
String statement = "SELECT left(table1.col1, 4) FROM table1";
assertSqlCanBeParsedAndDeparsed(statement);
}

public void testFunctionRight() throws JSQLParserException {
String statement = "SELECT right(table1.col1, 4) FROM table1";
assertSqlCanBeParsedAndDeparsed(statement);
}

public void testOracleJoin() throws JSQLParserException {
String stmt = "SELECT * FROM tabelle1, tabelle2 WHERE tabelle1.a = tabelle2.b(+)";
Expand Down

0 comments on commit 46f5197

Please sign in to comment.