Inclusion filtering in postgresql on a enum type column

254 Views Asked by At

I have a postgres enum create_enum(:status_type, %i[requested approved]). I created a column in a table with a status_type :status, null: false.

I am trying to filter with inclusion on it in ruby like this: root.where(requests[:status].in(*values). values is an array of strings.

This code returns the following error: Dry::Types::ConstraintError: ["requested"] violates constraints (included_in?(["requested", "approved"], ["requested"]) failed).

If I filter by equality on it, it works ok. root.where(requests[:status].is('requested')

Do you know a way for me to filter with inclusion on a custom type column?

0

There are 0 best solutions below