diff --git a/CHANGELOG.md b/CHANGELOG.md index f0e2e4f..18c41a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ See [keep a changelog] for information about writing changes to this log. ## [Unreleased] +## [1.1.1] - 2025-03-28 + +- Fix date range filter error for updated field + ## [1.1.0] - 2025-03-20 ### Added diff --git a/src/Api/Dto/DailyOccurrence.php b/src/Api/Dto/DailyOccurrence.php index 53622cd..1b89206 100644 --- a/src/Api/Dto/DailyOccurrence.php +++ b/src/Api/Dto/DailyOccurrence.php @@ -70,18 +70,18 @@ #[ApiFilter( DateRangeFilter::class, properties: [ - 'start' => 'start', - 'end' => 'end', - 'updated' => 'start', + 'start' => 'gte', + 'end' => 'lte', + 'updated' => 'gte', ], // Arguments only exist to provide backward compatibility with filters originally defined by the DateFilter arguments: [ 'config' => [ - 'start' => [ + 'gte' => [ 'limit' => DateLimit::gte, 'throwOnInvalid' => true, ], - 'end' => [ + 'lte' => [ 'limit' => DateLimit::lte, 'throwOnInvalid' => true, ], diff --git a/src/Api/Dto/Event.php b/src/Api/Dto/Event.php index b3dbd4a..9adb062 100644 --- a/src/Api/Dto/Event.php +++ b/src/Api/Dto/Event.php @@ -70,18 +70,18 @@ #[ApiFilter( DateRangeFilter::class, properties: [ - 'occurrences.start' => 'start', - 'occurrences.end' => 'end', - 'updated' => 'start', + 'occurrences.start' => 'gte', + 'occurrences.end' => 'lte', + 'updated' => 'gte', ], // Arguments only exist to provide backward compatibility with filters originally defined by the DateFilter arguments: [ 'config' => [ - 'start' => [ + 'gte' => [ 'limit' => DateLimit::gte, 'throwOnInvalid' => true, ], - 'end' => [ + 'lte' => [ 'limit' => DateLimit::lte, 'throwOnInvalid' => true, ], diff --git a/src/Api/Dto/Occurrence.php b/src/Api/Dto/Occurrence.php index 2a07746..e2c16ec 100644 --- a/src/Api/Dto/Occurrence.php +++ b/src/Api/Dto/Occurrence.php @@ -66,18 +66,18 @@ #[ApiFilter( DateRangeFilter::class, properties: [ - 'start' => 'start', - 'end' => 'end', - 'updated' => 'start', + 'start' => 'gte', + 'end' => 'lte', + 'updated' => 'gte', ], // Arguments only exist to provide backward compatibility with filters originally defined by the DateFilter arguments: [ 'config' => [ - 'start' => [ + 'gte' => [ 'limit' => DateLimit::gte, 'throwOnInvalid' => true, ], - 'end' => [ + 'lte' => [ 'limit' => DateLimit::lte, 'throwOnInvalid' => true, ], diff --git a/src/Api/Filter/ElasticSearch/DateRangeFilter.php b/src/Api/Filter/ElasticSearch/DateRangeFilter.php index 798dce2..8aff932 100644 --- a/src/Api/Filter/ElasticSearch/DateRangeFilter.php +++ b/src/Api/Filter/ElasticSearch/DateRangeFilter.php @@ -82,8 +82,12 @@ public function getDescription(string $resourceClass): array private function getElasticSearchQueryRanges($property, $filter): array { + if (null === $this->properties) { + throw new \InvalidArgumentException('The property must be defined in the filter.'); + } if (!\is_array($filter)) { - $operator = $this->config[$property]->limit; + $fallbackOperator = $this->properties[$property]; + $operator = $this->config[$fallbackOperator]->limit; $value = $filter; } else { $operator = DateLimit::{array_key_first($filter)};