[DBIx-Class-Devel] UPDATE RETURNING

fREW Schmidt frioux at gmail.com
Mon Jul 15 16:21:11 GMT 2013


On Mon, Jul 15, 2013 at 04:00:26PM +0000, Peter Rabbitson wrote:
> This is a very contrived use-case (I would simply solve it with batches
> wrapped in transactions), and I don't think it warrants a full blown
> chunk of the scrace API. You kind-of agree further down.

It's hardly contrived, that's actually how our application works.
Note that this code in our codebase is especially hot and deadlocks
are srs.  I am actually using raw sql to do what I am proposing
and skipping DBIC entirely because fewer DB interactions helps.

> I may misremember, but I think you can only return stored values, no
> aggreegates/subselects.

Yeah, that's true.  It can be complex math though, fwiw.

> > As for my "lazy" comment, imagine we supported the following:
> >
> >    say $_->name for $rs->search({
> >       id => {
> >          -in => $rs->update_returning({
> >             foo => 'bar'
> >          }, {
> >             columns => 'id', # or maybe better yet ->get_column('id')
> >          })->as_query
> >       }
> >    })->all
> >
> > So update_returning returns an unfetched resultset, just like search
> > does.
>
> I don't think many engines support this (may very well be Pg only,
> verify) - but afaik RETURNING does not yield to being treated as a
> subselect. That is its values are only available to be shoved in a
> cursor.
>

Yeah, you are probably right.  I can't seem to get this to work in
SSMS.

--
fREW Schmidt
http://blog.afoolishmanifesto.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/dbix-class-devel/attachments/20130715/29456b4d/attachment-0001.pgp


More information about the DBIx-Class-Devel mailing list