ash-project / ash_json_api

The JSON:API extension for the Ash Framework
https://hexdocs.pm/ash_json_api
MIT License
56 stars 40 forks source link

List query params causes a crash #93

Closed gordoneliel closed 1 year ago

gordoneliel commented 1 year ago

Describe the bug When filtering with list values eg. filter[status][in][0]=a&filter[status][in][1]=b, ash logs an error in the query because it does not handle list params.

To Reproduce Create an enum attribute status with values [:a, :b, :c]. Pass in for filters in a query: filter[status][in][0]=a&filter[status][in][1]=b

Ash query will embed an error:

  errors: [
    %Ash.Error.Unknown.UnknownError{
      error: "filter: Could not cast expression: Ash.Query.Operator.In status %{\"0\" => \"active\"}",
      field: nil,
      changeset: nil,
      query: nil,
      error_context: [],
      vars: [],
      path: [:filter],
      stacktrace: #Stacktrace<>,
      class: :unknown
    }
  ]

Expected behavior Should handle list query params and filter

** Runtime

zachdaniel commented 1 year ago

I think I accidentally led you astray on this initially. Try this filter[status][in][]=a&filter[status][in][]=b

gordoneliel commented 1 year ago

This works, closing!