File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
main/javacc/net/sf/jsqlparser/parser
test/java/net/sf/jsqlparser/test/select Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
193
193
| <K_NULL:"NULL">
194
194
| <K_LIKE:"LIKE">
195
195
| <K_REGEXP:"REGEXP">
196
+ | <K_REGEXP_LIKE:"REGEXP_LIKE">
196
197
| <K_DROP:"DROP">
197
198
| <K_JOIN:"JOIN">
198
199
| <K_LEFT:"LEFT">
@@ -1283,11 +1284,27 @@ Expression Condition():
1283
1284
}
1284
1285
{
1285
1286
(LOOKAHEAD(SQLCondition()) result=SQLCondition()
1286
- | result=RegularCondition())
1287
+ | result=FunctionCondition()
1288
+ | result=RegularCondition()
1289
+ )
1287
1290
1288
1291
{ return result; }
1289
1292
}
1290
1293
1294
+ Expression FunctionCondition():
1295
+ {
1296
+ Function result;
1297
+ ExpressionList parameters;
1298
+ }
1299
+ {
1300
+ <K_REGEXP_LIKE> { result = new Function(); result.setName("REGEXP_LIKE"); }
1301
+ "("
1302
+ parameters=SimpleExpressionList() { result.setParameters(parameters); }
1303
+ ")"
1304
+
1305
+ { return result; }
1306
+ }
1307
+
1291
1308
Expression RegularCondition():
1292
1309
{
1293
1310
Expression result = null;
Original file line number Diff line number Diff line change @@ -1022,4 +1022,14 @@ public void testPivotXml3() throws JSQLParserException {
1022
1022
assertSqlCanBeParsedAndDeparsed (stmt );
1023
1023
}
1024
1024
1025
+ public void testRegexpLike1 () throws JSQLParserException {
1026
+ String stmt = "SELECT * FROM mytable WHERE REGEXP_LIKE(first_name, '^Ste(v|ph)en$')" ;
1027
+ assertSqlCanBeParsedAndDeparsed (stmt );
1028
+ }
1029
+
1030
+ public void testRegexpLike2 () throws JSQLParserException {
1031
+ String stmt = "SELECT CASE WHEN REGEXP_LIKE(first_name, '^Ste(v|ph)en$') THEN 1 ELSE 2 END FROM mytable" ;
1032
+ assertSqlCanBeParsedAndDeparsed (stmt );
1033
+ }
1034
+
1025
1035
}
You can’t perform that action at this time.
0 commit comments