Skip to content

Commit 2229cb1

Browse files
committed
ESQL: Fix case-insensitive test generation with Unicodes (elastic#128753)
This excludes from testing the strings containing Unicode chars that change length when changing case. Closes elastic#128705 Closes elastic#128706 Closes elastic#128710 Closes elastic#128711 Closes Closes elastic#128717 Closes elastic#128789 Closes elastic#128790 Closes elastic#128791 Closes (cherry picked from commit 092d4ba)
1 parent 449a843 commit 2229cb1

File tree

1 file changed

+9
-2
lines changed
  • x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string

1 file changed

+9
-2
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeTests.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,15 @@ private static void casesForString(
9494
return new TextAndPattern(text, escapeString.apply(text));
9595
}, true);
9696
cases(cases, title + " matches self case insensitive", () -> {
97-
String text = textSupplier.get();
98-
return new TextAndPattern(randomCasing(text), escapeString.apply(text));
97+
// RegExp doesn't support case-insensitive matching for Unicodes whose length changes when the case changes.
98+
// Example: a case-insensitive ES regexp query for the pattern `weiß` won't match the value `WEISS` (but will match `WEIß`).
99+
// Or `ʼn` (U+0149) vs. `ʼN` (U+02BC U+004E).
100+
String text, caseChanged;
101+
for (text = textSupplier.get(), caseChanged = randomCasing(text); text.length() != caseChanged.length();) {
102+
text = textSupplier.get();
103+
caseChanged = randomCasing(text);
104+
}
105+
return new TextAndPattern(caseChanged, escapeString.apply(text));
99106
}, true, true);
100107
cases(cases, title + " doesn't match self with trailing", () -> {
101108
String text = textSupplier.get();

0 commit comments

Comments
 (0)