On Monday, June 8, 2015 at 7:43:40 AM UTC-7, Tiago Cardoso wrote:
>
> Hi,
>
> First of all, let me say that I've become a huge fan of this gem. Sequel
> is probably top-5 in the ruby world, and one could argue it is the only
> really "professional" gem of the bunch.
>
>
> I've been tasked with "translating" the queries in use on some obscure
> projects to plain ruby (or plain sequel). Some of these are quite
> complicated and I don't necessarily have the knowledge to rewrite them in a
> more convenient way, for which I just want to blatantly translate them to
> sequel-speak.
> One of them is quite complicated, though. I'll show you the complicated
> part:
>
> select cfs."all-ip_cfs_instance_id" as line,
>
> ...
> from
> ...
> table(cast(multiset
>
> (select table.column1,
> ....,
> ) as
> tableof10strings))(+) warp
>
> where ...
>
This should work:
DB.select(Sequel.qualify(:cfs,
Sequel.lit('all-ip_cfs_instance_id')).as(:line)).
from{Sequel.lit("table(cast(multiset ? as tableof10strings))(+) warp",
DB.select(:table__column1))}
It's possible to go a little further by abusing Sequel.lit, but I think the
above is better:
DB.select(Sequel.qualify(:cfs,
Sequel.lit('all-ip_cfs_instance_id')).as(:line)).
from{table(Sequel.cast(Sequel.lit("multiset ?",
DB.select(:table__column1)), :tableof10strings)).as(Sequel.lit("(+)
warp"))}
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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.