api-platform icon indicating copy to clipboard operation
api-platform copied to clipboard

`DateFilter` does not work with custom Doctrine ORM date types

Open emodric opened this issue 1 year ago • 3 comments

API Platform version(s) affected: 2.7.11

Description

I have a custom Doctrine ORM type for my date fields. Nothing special, only changes the format of the date string to be written to the database to add microtime.

The trouble is, DateFilter does not work with it, because it checks if the field type is in the list of hardcoded Doctrine types specified via ApiPlatform\Doctrine\Orm\Filter\DateFilter::DOCTRINE_DATE_TYPES.

Since the DateFilter class is final and all of it's methods are protected, I have no effective way of injecting my own Doctrine type into DateFilter, either by extending or decorating the filter class. The only way is to copy and paste the entire implementation which is not ideal.

I would like to see DateFilter improved to somehow allow flagging my own Doctrine type as safe to use by the filter.

Thanks!

emodric avatar Apr 18 '23 15:04 emodric

Hi,

I'm upgrading an old project from API Platform 2.6 to 3.1 and now I'm hitting this issue as well.

I had a custom filter that extends from DateFilter but now that class is final so I can't use it any more.

Can we just have the DateFilter not be final, please?

Thanks

pauljura avatar Sep 05 '23 06:09 pauljura

Same issue

SebLevDev avatar Feb 02 '24 10:02 SebLevDev

@same issue here!

medy36 avatar Aug 14 '24 09:08 medy36