Uh oh!
There was an error while loading. Please reload this page.
feat(doctrine): ComparisonFilter decorator for range filtering - #7760
Conversation
70600dc to
4b9b6acCompare70691cf to
314e0b7Compare| 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>
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
soyuka
commented
Mar 2, 2026
Thanks @KDederichs for the idea ! This replaces #4689 documentation is being worked on at api-platform/docs#2258 |
KDederichs
commented
Mar 2, 2026
Haha you're welcome :) |
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'].