Skip to content

Add test for LikeExpression.setEscape and LikeExpression.getStringExpression #1568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 7, 2022
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
*/
package net.sf.jsqlparser.expression.operators.relational;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
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.*;

/**
*
* @author Tobias Warneke (t.warneke@gmx.net)
Expand All @@ -25,4 +29,15 @@ public void testLikeNotIssue660() {
assertFalse(instance.isNot());
assertTrue(instance.withNot(true).isNot());
}

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

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