Skip to content

Commit

Permalink
regexp_like transfered into a general boolean function
Browse files Browse the repository at this point in the history
  • Loading branch information
wumpz committed Aug 11, 2013
1 parent 55f42ea commit 410a2d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/main/javacc/net/sf/jsqlparser/parser/JSqlParserCC.jj
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
| <K_INTO:"INTO">
| <K_NULL:"NULL">
| <K_LIKE:"LIKE">
| <K_REGEXP:"REGEXP">
| <K_REGEXP_LIKE:"REGEXP_LIKE">
| <K_DROP:"DROP">
| <K_JOIN:"JOIN">
| <K_LEFT:"LEFT">
Expand Down Expand Up @@ -1285,27 +1283,13 @@ Expression Condition():
}
{
(LOOKAHEAD(SQLCondition()) result=SQLCondition()
| result=FunctionCondition()
| result=RegularCondition()
| LOOKAHEAD(RegularCondition()) result=RegularCondition()
| result=Function()
)

{ return result; }
}

Expression FunctionCondition():
{
Function result;
ExpressionList parameters;
}
{
<K_REGEXP_LIKE> { result = new Function(); result.setName("REGEXP_LIKE"); }
"("
parameters=SimpleExpressionList() { result.setParameters(parameters); }
")"

{ return result; }
}

Expression RegularCondition():
{
Expression result = null;
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/net/sf/jsqlparser/test/select/SelectTest.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -1051,5 +1051,10 @@ public void testRegexpLike2() throws JSQLParserException {
String stmt = "SELECT CASE WHEN REGEXP_LIKE(first_name, '^Ste(v|ph)en$') THEN 1 ELSE 2 END FROM mytable";
assertSqlCanBeParsedAndDeparsed(stmt);
}

public void testBooleanFunction1() throws JSQLParserException {
String stmt = "SELECT * FROM mytable WHERE test_func(col1)";
assertSqlCanBeParsedAndDeparsed(stmt);
}

}

0 comments on commit 410a2d1

Please sign in to comment.