feat(doctrine): ComparisonFilter decorator for range filtering#7760
Open
soyuka wants to merge 2 commits intoapi-platform:mainfrom
Open
feat(doctrine): ComparisonFilter decorator for range filtering#7760soyuka wants to merge 2 commits intoapi-platform:mainfrom
soyuka wants to merge 2 commits intoapi-platform:mainfrom
Conversation
70600dc to
4b9b6ac
Compare
70691cf to
314e0b7
Compare
| Q | A | ------------- | --- | Branch? | main | Tickets | ∅ | License | MIT | Doc PR | ∅ Decorator-based ComparisonFilter that composes with equality filters (ExactFilter) to add gt, gte, lt, lte operators for both ORM and ODM. * ORM: injects $context['operator'] with DQL operators (>, >=, <, <=) * ODM: injects $context['comparisonMethod'] with MongoDB methods (gt, gte, lt, lte) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a decorator-style ComparisonFilter for Doctrine ORM/ODM to enable range-style query parameters by composing with existing equality filters (e.g., ExactFilter, UUID filters) via a context-provided comparison operator.
Changes:
- Introduces new ORM/ODM
ComparisonFilterimplementations and wires them into fixtures (Chicken + FilteredDateParameter) for functional coverage. - Extends ORM
ExactFilterandAbstractUuidFilter, plus ODMExactFilter, to honor a comparison operator/method coming from filter context. - Adds DateTime casting support for
castToNativeTypeparameters and new functional tests validating comparison behavior and OpenAPI parameter exposure.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Functional/Parameters/DateFilterTest.php | Adds scenarios for date range filtering via the new ComparisonFilter. |
| tests/Functional/Parameters/ComparisonFilterTest.php | New functional test validating gt/gte/lt/lte behavior and OpenAPI parameter names. |
| tests/Fixtures/TestBundle/Entity/FilteredDateParameter.php | Registers createdAtComparison QueryParameter using ComparisonFilter(ExactFilter) and native casting. |
| tests/Fixtures/TestBundle/Entity/Chicken.php | Adds idComparison QueryParameter using ComparisonFilter(ExactFilter). |
| tests/Fixtures/TestBundle/Document/FilteredDateParameter.php | ODM equivalent of createdAtComparison QueryParameter. |
| tests/Fixtures/TestBundle/Document/Chicken.php | ODM equivalent of idComparison QueryParameter. |
| src/State/Parameter/ValueCaster.php | Adds a DateTime caster intended for parameter native-type casting. |
| src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php | Auto-selects DateTime cast function when castToNativeType is enabled and the underlying property is DateTimeInterface. |
| src/Doctrine/Orm/Filter/ExactFilter.php | Allows a context-provided DQL operator (validated) instead of hardcoded =. |
| src/Doctrine/Orm/Filter/ComparisonFilter.php | New decorator filter that expands `{key}[gt |
| src/Doctrine/Orm/Filter/AbstractUuidFilter.php | Allows a context-provided DQL operator (validated) for UUID comparisons and respects whereClause. |
| src/Doctrine/Odm/Filter/ExactFilter.php | Adds a context-provided comparison method (validated) for non-reference fields. |
| src/Doctrine/Odm/Filter/ComparisonFilter.php | New ODM decorator filter expanding `{key}[gt |
| src/Doctrine/Odm/Extension/ParameterExtension.php | Preserves/restores prior context['filters'] around per-parameter filter application. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Decorator-based ComparisonFilter that composes with equality filters (ExactFilter, UuidFilter) to add gt, gte, lt, lte operators. Follows the same pattern as OrFilter by injecting $context['operator'].