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

Fixed OrderingFilter handling of empty values. #1628

Merged
merged 1 commit into from
Dec 5, 2023
Merged

Conversation

carltongibson
Copy link
Owner

@carltongibson carltongibson commented Dec 4, 2023

A trailing comma would cause a crash trying to map an empty value to a field name. Ensure sub-values are filtered for EMPTY_VALUES in addition to the main filter data.

Closes #1597.

Hi @munnsmunns, @scott-8. Sorry for the slow uptake: it was a while getting the bandwidth.

Here's an alternate take on #1598.

The behaviour of CSVWidget to map "," to ["",""] is covered by regression tests, so OrderingFilter needs to filter these prior to filtering. The natural place for such is in the filter method, where the empty check occurs for all filters.

If you have the space, could you give it a run and let me know if it works for you? Thanks.

A trailing comma would cause a crash trying to map an empty value to a
field name. Ensure sub-values are filtered for EMPTY_VALUES in
addition to the main filter data.

Closes #1597.

Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
@scott-8
Copy link

scott-8 commented Dec 4, 2023

Thanks for taking a look @carltongibson! I can confirm this works for me.

@munnsmunns
Copy link
Contributor

Works for me as well, thanks a bunch @carltongibson!

@carltongibson carltongibson merged commit 39bf174 into main Dec 5, 2023
9 checks passed
@carltongibson carltongibson deleted the pr/1598-alt branch December 5, 2023 08:10
@carltongibson
Copy link
Owner Author

Thanks both! Version 23.5 is available on PyPI now.

last-partizan pushed a commit to last-partizan/django-filter that referenced this pull request Sep 12, 2024
A trailing comma would cause a crash trying to map an empty value to a
field name. Ensure sub-values are filtered for EMPTY_VALUES in
addition to the main filter data.

Closes carltongibson#1597.

Co-authored-by: munnsmunns <mmunns16@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OrderingFilter triggers a 500 error if a single comma is given as the input
3 participants