On Wednesday, March 9, 2016 at 6:58:51 AM UTC-8, Ornella Bordino wrote:
>
> Good morning!
>
> I am trying to use ilike, but i am getting no where :(. If someone could
> help me, i would appreciate it.
>
> I am doing this:
>
> *Person.where(:name=>values).all*
>
> values is an array.
>
> And i need to add an 'ilike', so that 'values' can be ['pepe'] or ['Pepe'].
> Is there some syntaxis way that I am missing? or should i try to write
> pure sql?
>
> I tried to do something like:
> *Skill.where(Sequel.ilike(:name,/values/)).all* but sqlite doesnt support
> regex.
>
You probably want to use grep:
Skill.grep(:name, values, :case_insensitive=>true)
Note that this allows values to contain LIKE metacharacters, which is
probably a bad idea if values is derived from user input. This is safer:
Skill.grep(:name, values.map{|x| Skill.dataset.escape_like(x)},
:case_insensitive=>true)
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 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.