Skip to content

Commit 1d59430

Browse files
fix: Like, better use SimpleExpression only else there are precedence issues
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
1 parent 5b209f5 commit 1d59430

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4662,7 +4662,7 @@ Expression LikeExpression(Expression leftExpression) #LikeExpression:
46624662
| token = <K_MATCH_REGEXP>
46634663
) { result.setLikeKeyWord( LikeExpression.KeyWord.from(token.image)); }
46644664
[ LOOKAHEAD(2) <K_BINARY> {result.setUseBinary(true); } ]
4665-
rightExpression=Expression()
4665+
rightExpression=SimpleExpression()
46664666
[ LOOKAHEAD(2) <K_ESCAPE>
46674667
(
46684668
LOOKAHEAD(2) token = <S_CHAR_LITERAL> { result.setEscape( new StringValue( token.image ) ); }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +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-
"(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)");
70+
"(1.1 >= 2.3 OR S.A LIKE '\"%%%\"') AND (1.1 >= 2.3 OR S.B = '\"orz\"') AND (NOT 3.3 < 4.5 OR S.A LIKE '\"%%%\"') AND (NOT 3.3 < 4.5 OR S.B = '\"orz\"')");
7171
Expression result = CNFConverter.convertToCNF(expr);
7272
assertEquals(expected.toString(), result.toString());
7373
}
@@ -205,7 +205,7 @@ public void test5() throws Exception {
205205
"NOT ((NOT (S.A > 3.5 AND S.B < 4)) OR "
206206
+ "(S.C LIKE '\"%%\"' OR S.D = {t '12:04:34'}))");
207207
Expression expected = CCJSqlParserUtil.parseCondExpression(
208-
"S.A > 3.5 AND S.B < 4 AND NOT S.C LIKE '\"%%\"' OR S.D = {t '12:04:34'}");
208+
"S.A > 3.5 AND S.B < 4 AND NOT S.C LIKE '\"%%\"' AND NOT S.D = {t '12:04:34'}");
209209
Expression result = CNFConverter.convertToCNF(expr);
210210
assertEquals(expected.toString(), result.toString());
211211
}

0 commit comments

Comments
 (0)