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)

Most upvoted comments

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:

  • reverting the part of the PR that breaks this
  • add this to the next minor (future 2.7) but add an alternative

I think we can make SearchFilter ignore dates, and let DateFilter handle both formats: date[equal]=2020-12-31and date=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 adding equal.

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?