api-platform / api-platform/core

Probleme with DateFilter and ExistsFIlter on the same field

Offen
#7,993 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
filters
Vorherrschende Sprache
PHP
Sterne
2.6k
Forks
980
Ø Merge
2 T. 5 Std.
Gemergte PRs (30 T.)
48

Beschreibung

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 ?

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.