Skip to content

Commit bfbfc76

Browse files
committed
1 parent 68194bf commit bfbfc76

File tree

4 files changed

+50
-13
lines changed

4 files changed

+50
-13
lines changed

src/main/java/net/sf/jsqlparser/expression/operators/relational/LikeExpression.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@
2626

2727
public class LikeExpression extends BinaryExpression {
2828

29-
private boolean not = false;
29+
//private boolean not = false;
3030
private String escape = null;
3131
private boolean caseInsensitive = false;
3232

33-
@Override
34-
public boolean isNot() {
35-
return not;
36-
}
37-
38-
public void setNot(boolean b) {
39-
not = b;
40-
}
33+
// @Override
34+
// public boolean isNot() {
35+
// return not;
36+
// }
37+
//
38+
// public void setNot(boolean b) {
39+
// not = b;
40+
// }
4141

4242
@Override
4343
public void accept(ExpressionVisitor expressionVisitor) {
@@ -46,7 +46,7 @@ public void accept(ExpressionVisitor expressionVisitor) {
4646

4747
@Override
4848
public String getStringExpression() {
49-
return (not ? "NOT " : "") + (caseInsensitive ? "ILIKE" : "LIKE");
49+
return (isNot() ? "NOT " : "") + (caseInsensitive ? "ILIKE" : "LIKE");
5050
}
5151

5252
@Override

src/main/java/net/sf/jsqlparser/util/cnfexpression/CNFConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ private void handleNot(int index) {
378378
if(!(child instanceof MultiAndExpression) &&
379379
!(child instanceof MultiOrExpression)){
380380
if (child instanceof LikeExpression) {
381-
((LikeExpression) child).setNot(true);
381+
((LikeExpression) child).setNot();
382382
}else if(child instanceof BinaryExpression) {
383383
((BinaryExpression) child).setNot();
384384
}else {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,12 +2190,12 @@ Expression LikeExpression() #LikeExpression:
21902190
(
21912191
LOOKAHEAD(3) (
21922192
leftExpression=SimpleExpression()
2193-
[<K_NOT> { result.setNot(true); } ] ( <K_LIKE> | <K_ILIKE> { result.setCaseInsensitive(true); } ) rightExpression=SimpleExpression()
2193+
[<K_NOT> { result.setNot(); } ] ( <K_LIKE> | <K_ILIKE> { result.setCaseInsensitive(true); } ) rightExpression=SimpleExpression()
21942194
[<K_ESCAPE> token=<S_CHAR_LITERAL> { result.setEscape((new StringValue(token.image)).getValue()); }]
21952195
)
21962196
|
21972197
(
2198-
[<K_NOT> { result.setNot(true); } ] leftExpression=SimpleExpression() ( <K_LIKE> | <K_ILIKE> { result.setCaseInsensitive(true); } ) rightExpression=SimpleExpression()
2198+
[<K_NOT> { result.setNot(); } ] leftExpression=SimpleExpression() ( <K_LIKE> | <K_ILIKE> { result.setCaseInsensitive(true); } ) rightExpression=SimpleExpression()
21992199
[<K_ESCAPE> token=<S_CHAR_LITERAL> { result.setEscape((new StringValue(token.image)).getValue()); }]
22002200
)
22012201
)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2018 JSQLParser.
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2.1 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17+
* MA 02110-1301 USA
18+
*/
19+
package net.sf.jsqlparser.expression.operators.relational;
20+
21+
import static org.junit.Assert.*;
22+
import org.junit.Test;
23+
24+
/**
25+
*
26+
* @author Tobias Warneke ([email protected])
27+
*/
28+
public class LikeExpressionTest {
29+
30+
@Test
31+
public void testLikeNotIssue660() {
32+
LikeExpression instance = new LikeExpression();
33+
assertFalse(instance.isNot());
34+
instance.setNot();
35+
assertTrue(instance.isNot());
36+
}
37+
}

0 commit comments

Comments
 (0)