Repository navigation
Conversation
chiragjangiir
left a comment
There was a problem hiding this comment.
Code Review: Preserve blank filters in sort and CSV links
1. Context & Use Case
Datasette allows filtering columns by blank / empty values (column__exact="" or column__isnull=1). When clicking column header sort links or exporting to CSV/JSON via link bars, empty filter parameters were stripped out as falsy values by urllib.parse query builders.
2. Fix Analysis
- Modifies query parameter serialization to distinguish between omitted keys and keys explicitly set to empty string.
- CSV export URLs and sort toggles now faithfully preserve empty filter criteria.
3. Test Coverage
- Unit tests added asserting sorting on a table with an active empty-string filter preserves the filter parameter in generated URLs.
Clean fix resolving a common data exploration edge case.
agustin18
force-pushed
the
fix/blank-filter-links
branch
from
November 9, 2026 17:50
7e61cc6 to
3098446
Compare
Author
|
It looks like the new |
Owner
|
Superseded is good, but happy to review a fresh PR! |
Author
|
Thanks, Simon! I'll close this as superseded and look for another issue to help with. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3022
The URL helpers used
parse_qslwithoutkeep_blank_values=True, so a filter likecontent__exact=was dropped whenever a sort link rebuilt the query string. The request itself already keeps blank values, which is why the filter worked until one of those links was used.This preserves blank values in
path_with_added_args,path_with_removed_args, andpath_with_replaced_args. It also explicitly removes an empty_searchduring filter redirects, preserving the behavior covered bytest_empty_search_parameter_gets_removed.The CSV export form already keeps blank values on
main, so the HTML test covers the sort link.Verification
.venv/bin/pytest tests/test_utils.py tests/test_table_html.py tests/test_csv.py -q: 416 passed, 1 xfailedblackandruff: passed