On Wednesday, October 31, 2018 at 10:46:00 AM UTC-7, craig buchanan wrote:
>
> I'm trying to combine two case-insensitive LIKE clauses using an OR.
>
> This syntax:
>
> @tags = Tag.where( 
>         Sequel.or( Sequel[:name].ilike("%#{params[:name]}%") , Sequel[:
> description].ilike("%#{params[:name]}%") )
> )
>
>
> Generates an error:
>
> wrong number of arguments (given 2, expected 1)
>
> When I tried this syntax:
>
> ( Sequel[:name].ilike("%#{params[:name]}%") | Sequel[:description].ilike(
> "%#{params[:name]}%") )
>
> The query worked as expected.
>
> Is Sequel.or intended to be used in a limited set of cases?
>

As Stephen Weil pointed or, you want Sequel.|.  Sequel.or takes a single 
argument (a conditions specifier, either a hash or an array of pairs), and 
creates a boolean expression using the OR operator (Sequel.expr would use 
AND). Sequel.| takes any number of arguments and creates a boolean 
expression using the OR operator (Sequel.& would use AND).

The method naming is a little confusing to newcomers, admittedly, but they 
are two separate operations and need to be separate methods.

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 sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to