mirror of https://github.com/apache/druid.git
Like filter: Fix escapes escaping themselves. (#6295)
Escapes should escape themselves.
This commit is contained in:
parent
4caa61d8fa
commit
be6c901114
|
@ -116,7 +116,7 @@ public class LikeDimFilter implements DimFilter
|
||||||
SuffixMatch suffixMatch = SuffixMatch.MATCH_EMPTY;
|
SuffixMatch suffixMatch = SuffixMatch.MATCH_EMPTY;
|
||||||
for (int i = 0; i < likePattern.length(); i++) {
|
for (int i = 0; i < likePattern.length(); i++) {
|
||||||
final char c = likePattern.charAt(i);
|
final char c = likePattern.charAt(i);
|
||||||
if (escapeChar != null && c == escapeChar) {
|
if (escapeChar != null && c == escapeChar && !escaping) {
|
||||||
escaping = true;
|
escaping = true;
|
||||||
} else if (c == '%' && !escaping) {
|
} else if (c == '%' && !escaping) {
|
||||||
inPrefix = false;
|
inPrefix = false;
|
||||||
|
|
|
@ -206,6 +206,15 @@ public class LikeFilterTest extends BaseFilterTest
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEscapeEscapingItself()
|
||||||
|
{
|
||||||
|
assertFilterMatches(
|
||||||
|
new LikeDimFilter("dim1", "foooo", "o", null),
|
||||||
|
ImmutableList.of("1")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuffixMatchWithExtractionFn()
|
public void testSuffixMatchWithExtractionFn()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue