Skip to content

Commit 9b92cdf

Browse files
fix: Like Expression accepts Complex Expressions including BY PRIOR
- fixes #2158 Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
1 parent 19f0aa4 commit 9b92cdf

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4661,7 +4661,7 @@ Expression LikeExpression(Expression leftExpression) #LikeExpression:
46614661
| token = <K_MATCH_REGEXP>
46624662
) { result.setLikeKeyWord( LikeExpression.KeyWord.from(token.image)); }
46634663
[ LOOKAHEAD(2) <K_BINARY> {result.setUseBinary(true); } ]
4664-
rightExpression=SimpleExpression()
4664+
rightExpression=Expression()
46654665
[ LOOKAHEAD(2) <K_ESCAPE>
46664666
(
46674667
LOOKAHEAD(2) token = <S_CHAR_LITERAL> { result.setEscape( new StringValue( token.image ) ); }
@@ -5270,6 +5270,8 @@ Expression PrimaryExpression() #PrimaryExpression:
52705270

52715271
| retval=ConnectByRootOperator()
52725272

5273+
| retval=ConnectByPriorOperator()
5274+
52735275
| LOOKAHEAD(2, {!interrupted}) <K_ALL> { retval = new AllValue(); }
52745276

52755277
| LOOKAHEAD(2, {!interrupted}) retval=Column()

src/test/java/net/sf/jsqlparser/util/cnfexpression/CNFTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ public void test2() throws Exception {
6767
"((NOT (NOT 1.1 >= 2.3 OR 3.3 < 4.5)) OR "
6868
+ "(S.A LIKE '\"%%%\"' AND S.B = '\"orz\"'))");
6969
Expression expected = CCJSqlParserUtil.parseCondExpression(
70-
"(1.1 >= 2.3 OR S.A LIKE '\"%%%\"') AND (1.1 >= 2.3 OR S.B = '\"orz\"')"
71-
+ " AND (NOT 3.3 < 4.5 OR S.A LIKE '\"%%%\"') AND (NOT 3.3 < 4.5 OR S.B = '\"orz\"')");
70+
"(S.A LIKE '\"%%%\"' AND S.B = '\"orz\"' OR 1.1 >= 2.3) AND (S.A LIKE '\"%%%\"' AND S.B = '\"orz\"' OR NOT 3.3 < 4.5)");
7271
Expression result = CNFConverter.convertToCNF(expr);
7372
assertEquals(expected.toString(), result.toString());
7473
}
@@ -206,8 +205,7 @@ public void test5() throws Exception {
206205
"NOT ((NOT (S.A > 3.5 AND S.B < 4)) OR "
207206
+ "(S.C LIKE '\"%%\"' OR S.D = {t '12:04:34'}))");
208207
Expression expected = CCJSqlParserUtil.parseCondExpression(
209-
"S.A > 3.5 AND S.B < 4 AND NOT S.C LIKE '\"%%\"' "
210-
+ "AND NOT S.D = {t '12:04:34'}");
208+
"S.A > 3.5 AND S.B < 4 AND NOT S.C LIKE '\"%%\"' OR S.D = {t '12:04:34'}");
211209
Expression result = CNFConverter.convertToCNF(expr);
212210
assertEquals(expected.toString(), result.toString());
213211
}

0 commit comments

Comments
 (0)