Skip to content

Commit ec44a98

Browse files
committed
like + set escape test for $ as escape character
1 parent 3b39397 commit ec44a98

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/test/java/net/sf/jsqlparser/expression/operators/relational/LikeExpressionTest.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
*/
1010
package net.sf.jsqlparser.expression.operators.relational;
1111

12+
import net.sf.jsqlparser.JSQLParserException;
13+
import net.sf.jsqlparser.expression.Expression;
14+
import net.sf.jsqlparser.expression.StringValue;
15+
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
1216
import org.junit.jupiter.api.Test;
1317

1418
import static org.junit.jupiter.api.Assertions.*;
@@ -27,10 +31,13 @@ public void testLikeNotIssue660() {
2731
}
2832

2933
@Test
30-
public void testSetEscapeAndGetStringExpression() {
31-
LikeExpression instance = new LikeExpression();
32-
LikeExpression instance2 = new LikeExpression();
34+
public void testSetEscapeAndGetStringExpression() throws JSQLParserException {
35+
LikeExpression instance = (LikeExpression) CCJSqlParserUtil.parseExpression("a LIKE 'J%$_%'");
36+
// escape character should be $
37+
Expression instance2 = new StringValue("$");
3338
instance.setEscape(instance2);
34-
assertEquals("null LIKE null ESCAPE null LIKE null", instance.toString());
39+
40+
// match all records with names that start with letter ’J’ and have the ’_’ character in them
41+
assertEquals("a LIKE 'J%$_%' ESCAPE '$'", instance.toString());
3542
}
3643
}

0 commit comments

Comments
 (0)