core: BC Break on SearchFilter with date as input
API Platform version(s) affected: x.y.z
Description
If you use dates with the search filter, this was supported, it now triggers an exception. This is because previously the type was not always sent with the doctrine parameter, and doctrine was considering the date as string type (which is valid when you have a string like 2021-01-12 as input).
How to reproduce
If you have the following filter configured on an entity, it will break:
/**
* ...
* @ApiFilter(SearchFilter::class, properties={"something.id": "exact", "date": "exact"})
*/
Possible Solution
Add support for dates, which is a special case that is not that simple because it requires to manage date, datetime, datetime_immutable and so on.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 28 (25 by maintainers)
Should be fixed in 2.6.4 now
IMHO #3774 should not have break this anyways especially in a patch I’d be in favor of:
I think we can make
SearchFilterignore dates, and letDateFilterhandle both formats:date[equal]=2020-12-31anddate=2020-12-31. this would mitigate the BC break. WDYT?Not sure why there is no
equal. Maybe @dunglas has an idea? Personally, I’m OK of addingequal.Related: https://github.com/api-platform/core/issues/241 Maybe adding an exception when using a search filter in a date property would be a good thing?