Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute searching: search strings lexicographically #952

Closed
yankovs opened this issue Jul 8, 2024 · 2 comments · Fixed by #953
Closed

Attribute searching: search strings lexicographically #952

yankovs opened this issue Jul 8, 2024 · 2 comments · Fixed by #953
Labels
type:bug Something isn't working zone:backend MWDB backend core related tasks

Comments

@yankovs
Copy link
Contributor

yankovs commented Jul 8, 2024

Hey!

This might have been a change in the recent search refactoring, but this query for a string attribute results in an error:
image

However, comparing strings lexicographically does make sense in some cases. For example, if the strings are ISO 8601 format dates

@yankovs
Copy link
Contributor Author

yankovs commented Jul 8, 2024

Edit: I think this isn't an issue with the string comparison, but with the - in the string.

@psrok1 psrok1 added the type:bug Something isn't working label Jul 8, 2024
@psrok1
Copy link
Member

psrok1 commented Jul 8, 2024

🤔 Yeah, I think it's more a bug. Search like that is converted to the jsonpath query value @? '$.vt.last_analysis_str ? @ <= 2024-07-07 because I assumed that range queries can be done only with numerical values. Unfortunately that assumption doesn't come with any validation.

If lexicographical compare works with jsonpath, I think it's just enough to add quotes and proper escapes when queried value doesn't look like a number (using jsonpath_quote -

def jsonpath_quote(value: str) -> str:
). Of course there will be still a corner case with numbers represented as strings, but I guess it's not that important.

I'll try to fix that soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working zone:backend MWDB backend core related tasks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants