Skip to content

cql2_like_to_es() does not correctly convert #285

Closed
@kurtmckee

Description

@kurtmckee

Describe the bug

cql2_like_to_es() doesn't handle escaped backslashes, which leads to the following problems:

  • '\\' (an escaped backslash) is not converted to '\'.
  • '\\%' (an escaped backslash followed by a wildcard) is not converted to '\*'
  • '\\\% (an escaped backslash followed by an escaped percent sign) is not converted to '\%'.
  • '\\_' (an escaped backslash followed by a wildcard) is not converted to '\?'.
  • '\\\_' (an escaped backslash followed by an escaped underscore) is not converted to '\_'.

In addition, CQL2 doesn't appear to define what should happen when a trailing escape character is encountered (like 'abc\') nor what to do with an invalid escape sequence (like '\1').

I recommend rejecting invalid/incomplete escape sequences.

To Reproduce

I'll be posting a PR with a break/fix momentarily for evaluation.

Expected behavior

I expected cql2_like_to_es() to understand escaped backslashes.

Screenshots
n/a

Desktop (please complete the following information):
n/a, this is a bug in the Python implementation

Smartphone (please complete the following information):
n/a

Additional context
n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions