On Wednesday, May 10, 2017 at 2:17:58 AM UTC-7, Wojciech Maciejak wrote:
>
> Hello, Jeremy and community!
> I have a small issue with *position* function.
>
> I created query with small part
> where { "position(geolocations.path in '#{geolocation}') > 0" } # => WHERE
> (position(geolocations.path in 'PL.DOL') > 0)
> It works brilliant, but I wanna did everything which is possible with
> sequel functions.
> I tried code similar to this, but it produces not valid SQL code.
> where(Sequel.function(:position, geolocations__path: geolocation) > 0 ) #
> => WHERE (position(("geolocations"."path" = 'PL.DOL')) > 0)
>
> What do I wrong?
>
I don't think Sequel supports an IN 'string literal' operator, so you would
probably have to use literal SQL for that part:
where{position(Sequel.lit('geolocations.path in ?', geolocation)) > 0}
>From reviewing the PostgreSQL documentation, it would probably be best to
use strpos instead, since then you don't need literal SQL:
where{strpos(geolocation, Sequel[:geolocations][:path])}
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.