Skip to content

Commit

Permalink
allow more complex expressions in extract clause
Browse files Browse the repository at this point in the history
  • Loading branch information
wumpz committed Apr 18, 2013
1 parent 8562d78 commit ab2ab73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/javacc/net/sf/jsqlparser/parser/JSqlParserCC.jj
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ ExtractExpression ExtractExpression() :
"("
token=<S_IDENTIFIER> { retval.setName(token.image); }
<K_FROM>
expr=PrimaryExpression() { retval.setExpression(expr); }
expr=SimpleExpression() { retval.setExpression(expr); }
")"
{
return retval;
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 @@ -763,6 +763,16 @@ public void testExtractFrom2() throws JSQLParserException {
String stmt = "SELECT EXTRACT(year FROM now()) FROM testtable";
assertSqlCanBeParsedAndDeparsed(stmt);
}

public void testExtractFrom3() throws JSQLParserException {
String stmt = "SELECT EXTRACT(year FROM (now() - 2)) FROM testtable";
assertSqlCanBeParsedAndDeparsed(stmt);
}

public void testExtractFrom4() throws JSQLParserException {
String stmt = "SELECT EXTRACT(minutes FROM now() - '01:22:00') FROM testtable";
assertSqlCanBeParsedAndDeparsed(stmt);
}

public void testProblemFunction() throws JSQLParserException {
String stmt = "SELECT test() FROM testtable";
Expand Down

0 comments on commit ab2ab73

Please sign in to comment.