Filtering by enum attribute
I have an Ash resource that has an enum field
status
. Im using AshJsonApi to pass in a filter: filter[status]=active,incomplete
. This doesnt seem to work out of the box so I implemented a preperation where I do this:
This does not work however, returns the following error:
Is there an example or an way to filter by an enum?5 Replies
Inspecting the filter after adding my customer status filter, it looks like there is an original filter to find status but the direct string sent from the api through AshJsonApi:
filter[status][in][0]=active&filter[status][in][1]=incomplete
should do itDo I have to write a custom filter expression for this or can it be handled automatically?
Getting an error when running with the array filter:
Whats also odd is that in the example repos for ash, the case on get_argument for filter has atom keys, but mine has string keys 🧐
that should be fine...
I think this may be something we're missing in
ash_json_api
, we should be handling list query params like that properly and creating lists
can you open a bug in ash_json_api
?
I can fix it when I get the chanceAdded!
In case anyone else runs into this, to filter by multiple values in an enum attribute, you need to filters your query params like so
filter[status][in]=a&filter[status][in]=b where a & b are possible enum values