api-platform / api-platform/core

Probleme with DateFilter and ExistsFIlter on the same field

Đang mở
#7,993 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
filters
Ngôn ngữ chính
PHP
Star
2.6k
Fork
980
Merge trung bình
2 ngày 5 giờ
Pull request đã merge (30 ngày)
48

Mô tả

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 ?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.