api-platform / api-platform/core

Probleme with DateFilter and ExistsFIlter on the same field

未关闭
#7,993 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
filters
主要语言
PHP
星标
2.6k
派生
980
平均合并
2 天 5 小时
30 天内合并 PR
48

描述

Hi team,

First, thank you again for make my life easier with api-platform !

I've got an issue when i put a DateFIlter and an ExistsFilter on the same property.

The property :
```
/**
* @var \DateTime
*
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"get", "post", "put"})
*/
private $started;
```

The date filter :

```
@ApiFilter(DateFilter::class,
* properties={
* "started": DateFilter::EXCLUDE_NULL,
* }
* )

```

The ExistsFilter :

```
* @ApiFilter(ExistsFilter::class, properties={"started"})
```

With this code, i make request on client-side with params : 'started[exists]' to 'false'. Should return data with started = null;
But the date filter stop the exists filter because of the 'EXCLUDE_NULL'. In fact, i resolve this issue by update the DateFIlter like this
```
* "started": DateFilter::INCLUDE_NULL_BEFORE,
```
The 'INCLUDE_NULL' resolve the issue, but i think it isn't a normal comportement.
The DateFIlter that exclud null value should not affect ExistsFilter, isn't it ?
Or do i miss somthing ?

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。