[Dbix-class] [PATCH] Add support for 'INSERT ... RETURNING' to SQL::Abstract

Peter Rabbitson rabbit+dbic at rabbit.us
Mon Jan 11 10:24:45 GMT 2010


Oliver Charles wrote:
> This was original part of my SQL::Abstract::Plugin::InsertReturning
> [1] module, but mst expressed interest in having this become part of
> core. So here it is!
> 
> This adds an extra parameter to SQL::Abstract->insert, \%options,
> which can take additional options to generate the query. At the moment
> this obviously only supports the 'returning' option. I've added
> documentation about how this option is used, along with some tests to
> ensure correctness.
> 
> I hope this helps, I'm open to feedback if it needs to be improved.
> 

Hi, nice work. There is a slight problem with how you are treating a
single scalar. In SQLA the general prinicple is that if you want to
pass random strings, you pass \'...stuff...' (scalarref). Anything
else is subject to quoting (which you do not test). So for example
I would expect returning => 'id, foo, bar' } to generate
...  RETURNING "id, foo, bar"
when quoting is engaged. Please augment the tests and introduce
scalarref handling (scalar should be treated as 1-element arrayref)

Also if you prefer to work on a branch I or mst can set you up with
a commit bit to the repo. Drop either one of us a line in #dbix-class



More information about the DBIx-Class mailing list