Skip to content

Commit 4dfffd7

Browse files
committed
Escape special ES character when used in pattern matching
1 parent f3dd1ea commit 4dfffd7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pg_es_fdw/_es_query.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@ def _pg_es_pattern_map(matchobj):
3535
return "%"
3636
elif matchobj.group(0) == "\_":
3737
return "_"
38+
elif matchobj.group(0) == "*":
39+
return "\\*"
40+
elif matchobj.group(0) == "?":
41+
return "\\?"
3842
elif matchobj.group(0) == "\\\\":
3943
return "\\"
4044

41-
return re.sub(r'\\\\|\\?%|\\?_', _pg_es_pattern_map, fr"{expr}")
45+
return re.sub(r'\\\\|\\?%|\\?_|\*|\?', _pg_es_pattern_map, fr"{expr}")
4246

4347

4448
def _base_qual_to_es(col, op, value, column_map=None):

0 commit comments

Comments
 (0)