Repository navigation
Conversation
Filtering so far only supported exact matches, so numeric, date and datetime columns could not be narrowed to an interval without writing a custom backend (the very example the docs used to illustrate BaseFilter). RangeFilter follows the existing backend contract: whitelist columns in Meta.filtering.ranges and each one accepts ?<field>_min= (col >= value) and ?<field>_max= (col <= value). The two bounds are independent, values are coerced to the column type (int, float/Numeric, date, datetime via ISO 8601), and a bound that cannot be coerced is ignored the same way an unknown ?ordering= field is. Because a range is meaningless on an unordered column, Meta.filtering.ranges is validated in RestEndpointMeta against the endpoint's declared and auto-injected columns, raising ConfigurationError at class definition time for an unknown field or a String/Boolean one. Reflected endpoints have no declared columns and are skipped. YAML config gains a matching ranges: key, which auto-selects the backend like fields/search/ordering already do, and RangeFilter is resolvable by name in backends:. Covered by tests/test_range_filter.py (numeric, datetime, auto-injected columns, ignored params, composition, config validation) plus a YAML auto-selection case; README, docs/advanced/filtering.md, docs/api-reference/filters.md and examples/08_filtering.py updated. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This branch has not been deployed
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.
Filtering so far only supported exact matches, so numeric, date and datetime columns could not be narrowed to an interval without writing a custom backend (the very example the docs used to illustrate BaseFilter).
RangeFilter follows the existing backend contract: whitelist columns in Meta.filtering.ranges and each one accepts ?_min= (col >= value) and ?_max= (col <= value). The two bounds are independent, values are coerced to the column type (int, float/Numeric, date, datetime via ISO 8601), and a bound that cannot be coerced is ignored the same way an unknown ?ordering= field is.
Because a range is meaningless on an unordered column, Meta.filtering.ranges is validated in RestEndpointMeta against the endpoint's declared and auto-injected columns, raising ConfigurationError at class definition time for an unknown field or a String/Boolean one. Reflected endpoints have no declared columns and are skipped.
YAML config gains a matching ranges: key, which auto-selects the backend like fields/search/ordering already do, and RangeFilter is resolvable by name in backends:.
Covered by tests/test_range_filter.py (numeric, datetime, auto-injected columns, ignored params, composition, config validation) plus a YAML auto-selection case; README, docs/advanced/filtering.md, docs/api-reference/filters.md and examples/08_filtering.py updated.