Skip to content

Filters: use the same param name for different filters #8391

Description

@emmanuel-nz

Description
Hi,
first of all, thanks for the great work on the new filters, it's a great improvement, they are very nice and very powerful.

For the same property, sometimes I need to check if it is greater or lower than a specific value, and sometimes I need to check if it is strictly equal.
For example, for a date:

  • ?foo[gt]=2026-01-01
  • and in an other context: ?foo=2026-01-01

With the current way of declaring filters, I can't declare the same param with 2 different filters (here, ComparisonFilter and ExactFilter).

parameters: [
    'foo' => new QueryParameter(
        filter: new ExactFilter(),
    ),
    'foo' => new QueryParameter( // <-- HERE: can't declare the same parameter twice, since it is an associative array, the second declaration will override the first one
        filter: new ComparisonFilter(new ExactFilter()),
    ),
]

One solution could be to allow to pass an array to QueryParameter.filter (or to add a new filters property to QueryParameter)

Example

parameters: [
    'foo' => new QueryParameter(
        filter: [new ExactFilter(), new ComparisonFilter(new ExactFilter())],
    ),
]

It would be nice to have such a feature, because currently, as a workaround we need to alias the parameter name, which is a shame (to me, at least) for such a simple case.

parameters: [
    'foo' => new QueryParameter(
        filter: new ExactFilter(),
    ),
    'fooCompare' => new QueryParameter(
        filter: new ComparisonFilter(new ExactFilter()),
        property: 'foo',
    ),
]

And if I need to use a third filter for the same property, it will force me to create a third alias, and so on...

An another, maybe, simpler (but more limited) solution, for my specific use case, would be to allow = as an operator for the ComparisonFilter.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions