Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
like + set escape test for $ as escape character
  • Loading branch information
lacinoire committed Jun 30, 2022
commit d84bb5f247ea8bc46dc508737b1117e7b50a50e8
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
*/
package net.sf.jsqlparser.expression.operators.relational;

import net.sf.jsqlparser.JSQLParserException;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.StringValue;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import org.junit.jupiter.api.Test;

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

@Test
public void testSetEscapeAndGetStringExpression() {
LikeExpression instance = new LikeExpression();
LikeExpression instance2 = new LikeExpression();
public void testSetEscapeAndGetStringExpression() throws JSQLParserException {
LikeExpression instance = (LikeExpression) CCJSqlParserUtil.parseExpression("name LIKE 'J%$_%'");
// escape character should be $
Expression instance2 = new StringValue("$");
instance.setEscape(instance2);
assertEquals("null LIKE null ESCAPE null LIKE null", instance.toString());

// match all records with names that start with letter ’J’ and have the ’_’ character in them
assertEquals("name LIKE 'J%$_%' ESCAPE '$'", instance.toString());
}
}