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 摘要。