[Dbix-class] Updates on joins

Robert Rothenberg robrwo at gmail.com
Sat Feb 23 16:19:15 GMT 2019


How do I do an update on a join where the value is based on the joined
table, e.g. something like

  UPDATE t1
    SET t1.c1 = CONCAT(t1.c2, t2.c3)
  FROM
    t2
  WHERE t1.id=t2.id AND t2.c1 IS NULL;

I've had trouble using DBIC and had to resort to a custom, hackish
`update_from` method, but before I do any further work to turn it into a
generic DBIC component for CPAN, is there already a way to do this with
existing DBIC or add-ons for DBIC?

FWIW, I'm using Postgres but as far as I know most databases handle UPDATE
FROM syntax (with the exception of MySQL, unsurprisingly, which uses UPDATE
JOIN).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20190223/fe8d1957/attachment.htm>


More information about the DBIx-Class mailing list