Like filter: Fix escapes escaping themselves. (#6295)

Escapes should escape themselves.
This commit is contained in:
Gian Merlino 2018-09-05 09:29:07 -07:00 committed by Fangjin Yang
parent 4caa61d8fa
commit be6c901114
2 changed files with 10 additions and 1 deletions

View File

@ -116,7 +116,7 @@ public class LikeDimFilter implements DimFilter
SuffixMatch suffixMatch = SuffixMatch.MATCH_EMPTY;
for (int i = 0; i < likePattern.length(); i++) {
final char c = likePattern.charAt(i);
if (escapeChar != null && c == escapeChar) {
if (escapeChar != null && c == escapeChar && !escaping) {
escaping = true;
} else if (c == '%' && !escaping) {
inPrefix = false;

View File

@ -206,6 +206,15 @@ public class LikeFilterTest extends BaseFilterTest
);
}
@Test
public void testEscapeEscapingItself()
{
assertFilterMatches(
new LikeDimFilter("dim1", "foooo", "o", null),
ImmutableList.of("1")
);
}
@Test
public void testSuffixMatchWithExtractionFn()
{