I believe you should use .or like this:

@tags = Tag.where(Sequel[:name].ilike("%#{params[:name]}%")).or(Sequel[:
description].ilike("%#{params[:name]}%"))

If you want to use an or statement as you outlined, you can use Sequel.|

@tags = Tag.where(
        Sequel.|( Sequel[:name].ilike("%#{params[:name]}%") , Sequel[:
description].ilike("%#{params[:name]}%") )
)

Of course you can also use the | operator within a where(), as you noted.

I can't speak to the when Sequel.or vs | is intended to be used, but I
generally use `.or` only for simple (x OR y) conditions, and use | when I
need to build more complicated/logically grouped conditions. I would be
curious to know if there are performance benefits to using one method or
the other in certain situations. Perhaps Jeremy or someone else can shed
some light on that.

On Wed, Oct 31, 2018 at 12:46 PM craig buchanan <[email protected]> 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?
>
> Thanks.
>
> --
> 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 post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sequel-talk.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to [email protected].
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