On Thursday, February 19, 2015 at 5:55:01 AM UTC-8, Paulo Luis Franchini
Casaretto wrote:
>
> I'm in the process of replacing a lot of hand generated SQL queries.
> I can't thank you enough for this gem, specially for the pg extensions.
> But there is one particular query that's bothering me:
>
> https://gist.github.com/pcasaretto/d2772d78d32db42a98b5
>
> It uses postgres functionality described in:
>
> http://www.postgresql.org/docs/9.3/static/sql-update.html
>
> Is there any way to generate that query with Sequel as of now?
>
Yes. Here's the basic structure:
DB.from(:leads___l, DB.values([[...], [...], ...]).as(:u, [:id,
:job_title, :name, :uf, :bio, :pg_tags])).
where(:u__id=>:l__id).
update(:job_title=>Sequel.expr{COALESCE(NULLIF(:u__job_title, ''),
:l__job_title), ...})
Hopefully you can fill in the details. If you have questions, please reply.
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.