woylie/flop

[Bug]

patric-vinicios opened this issue · 1 comments

Summary

In my tests with allowed_operators I tried to send a field that is not in my schema in field param.
I don't know if it is the normal behavior of the function. If it is, please, ignore this issue.

Steps to reproduce

  1. Flop.Filter.allowed_operators(Pet, :example_field)

Expected behaviour

{:error, "Field not found in schema."}

Actual behaviour

** (FunctionClauseError) no function clause matching in Flop.Schema.Pet."-inlined-field_info/2-"/2    
    
    The following arguments were given to Flop.Schema.Pet."-inlined-field_info/2-"/2:
    
        # 1
        %Pet{
          __meta__: #Ecto.Schema.Metadata<:built, "pets">,
          id: nil,
          name: nil,
          age: nil,
          species: nil
        }
    
        # 2
        :example_field
    
    (flop 0.23.0) Flop.Schema.Pet."-inlined-field_info/2-"/2
    (flop 0.23.0) lib/flop/filter.ex:244: Flop.Filter.allowed_operators/2
    iex:5: (file)

Elixir/Erlang version

Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns]

Elixir 1.15.4 (compiled with Erlang/OTP 26)

Flop and Ecto versions

{:ecto, "~> 3.10.3"},

Flop actual version.

Additional context

No response

woylie commented

That's expected, this function is only meant to be called on known fields.