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

Feature request: filter like and ilike #421

Open
usernein opened this issue May 29, 2020 · 6 comments · May be fixed by #954
Open

Feature request: filter like and ilike #421

usernein opened this issue May 29, 2020 · 6 comments · May be fixed by #954
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@usernein
Copy link

Example of usage:

users = await User.filter(first_name__ilike="c%r")

I know this can be done with startswith and endswith, but there are cases where using the LIKE operator is better:

users = await User.filter(first_name__ilike="j_r%")

This would be used to match Jeremy, Jorge, Jordan...

@abondar abondar added enhancement New feature or request good first issue Good for newcomers labels May 29, 2020
@WisdomPill
Copy link

I would like to work on it this weekend, @abondar can you assign it to me please?

@grigi
Copy link
Member

grigi commented May 29, 2020

@WisdomPill You don't need it assigned to you if you want to work on it. Just state you want to?

I thought about this and SQL Injection abilities, differentiating between _(the match operator) and \_(the literal) is going to be hard.
We would need to keep track of \_ and \% separately from other \'s, else we open ourselves up for SQL-Injection.

I think we can do it safely, but will definitely have to apply lots of scrutiny/testing to this.

@WisdomPill
Copy link

Okay, I thought that because there are projects on this repository that assignation is the way to go, good to know.

I think we can do it safely, but will definitely have to apply lots of scrutiny/testing to this.

For sure first thing to do is to add some tests with skip so that in the first commits of the pull request can be used to assess that there is no sql injection possibility

@grigi
Copy link
Member

grigi commented May 29, 2020

We are not too strict on anything here. Except possibly the code. But even there I have worked with projects where there is some kind of tribal agreement as to how code should be written. As long as the CI passes and there isn't an obviously better way of doing things, it's all good. Just look at the abomination that is our test helpers :-( They are really showing their age, and possibly a reason to bump major version as it affects a lot of people.

@simoncampion simoncampion linked a pull request Oct 16, 2021 that will close this issue
7 tasks
@thisisthemurph
Copy link

Has this been implemented, I have searched the documentation, but I can't find anything there. May be my searching abilities.

@thisisthemurph
Copy link

Ok, a little more searching let me to the correct location. This seems to have been implemented as contains and icontains.

https://tortoise.github.io/query.html#filtering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants