Ah, I see. I figured there was a good explanation for it. Thanks Jeremy! 
Have a great weekend. 

On Friday, January 14, 2022 at 11:37:43 AM UTC-6 Jeremy Evans wrote:

> On Fri, Jan 14, 2022 at 9:29 AM 'Mike Pastore' via sequel-talk <
> [email protected]> wrote:
>
>> Hi Jeremy,
>>
>> I have an `agent_role' enum type in my Postgres database, and a table 
>> with a `roles' column, type `agent_role[]'. I'd like to filter records in 
>> this table where the `roles' column contains a certain `agent_role'.  
>>
>> This works:
>>
>>     .where('sales_representative'=>Sequel[:roles].pg_array.any) # 
>> => ('sales_representative' = ANY("roles"))
>>
>> But I can't seem to make this work (the terms get reversed and Postgres 
>> doesn't like it):
>>
>>     .where { 'sales_representative' =~ roles.pg_array.any } # 
>> => (ANY("roles") = 'sales_representative'))
>>
>
> This isn't a Sequel issue, but a Ruby issue.  string =~ arg calls arg =~ 
> string (this is how String#=~ behaves in Ruby).
>
> You can get the behavior you want by wrapping the string in a Sequel 
> object:
>
>  .where {Sequel['sales_representative'] =~ roles.pg_array.any }
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/daab47c7-7760-4e5b-99c0-109b01e60335n%40googlegroups.com.

Reply via email to