Ash FrameworkAF
Ash Framework3y ago
14 replies
dblack

FilterForm inspect strange behavior

I'm just playing around with FilterForm and I'm seeing some weird inspect behavior, which is not making it easy to reason with what's going on. For instance:

filter_form = FilterForm.new(Property)
{filter_form, group_id} = FilterForm.add_group(filter_form, operator: :or, return_id?: true)
filter_form = FilterForm.add_predicate(filter_form, :id, :eq, nil, to: group_id)

IO.inspect(filter_form)


Gives me:

%AshPhoenix.FilterForm.Predicate{
  id: "0b9cab33-2194-475e-a010-407d5964a8ec",
  field: :id,
  value: nil,
  transform_errors: nil,
  operator: :eq,
  params: %{
    "field" => :id,
    "id" => "0b9cab33-2194-475e-a010-407d5964a8ec",
    "operator" => :eq,
    "value" => nil
  },
  arguments: %AshPhoenix.FilterForm.Arguments{
    input: %{},
    params: %{},
    arguments: [],
    errors: []
  },
  negated?: false,
  path: [],
  errors: [],
  valid?: true
}


I would have expected a FilterForm struct. I've validated that filter_form is actually a FilterForm and not a FilterForm.Predicate? Is this a bug with the inspect protocol for FilterForm's or am I totally misunderstanding something (likely)!
Was this page helpful?