[Bast-commits] r8934 - SQL-Abstract/1.x/trunk/lib/SQL
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Sun Mar 7 21:51:20 GMT 2010
Author: ribasushi
Date: 2010-03-07 21:51:20 +0000 (Sun, 07 Mar 2010)
New Revision: 8934
Modified:
SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm
Log:
Factor out insert returning generator
Modified: SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm
===================================================================
--- SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm 2010-03-07 11:08:00 UTC (rev 8933)
+++ SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm 2010-03-07 21:51:20 UTC (rev 8934)
@@ -118,18 +118,24 @@
my ($sql, @bind) = $self->$method($data);
$sql = join " ", $self->_sqlcase('insert into'), $table, $sql;
- if (my $fields = $options->{returning}) {
- my $f = $self->_SWITCH_refkind($fields, {
- ARRAYREF => sub {join ', ', map { $self->_quote($_) } @$fields;},
- SCALAR => sub {$self->_quote($fields)},
- SCALARREF => sub {$$fields},
- });
- $sql .= join " ", $self->_sqlcase(' returning'), $f;
+ if (my $ret = $options->{returning}) {
+ $sql .= $self->_insert_returning ($ret);
}
return wantarray ? ($sql, @bind) : $sql;
}
+sub _insert_returning {
+ my ($self, $fields) = @_;
+
+ my $f = $self->_SWITCH_refkind($fields, {
+ ARRAYREF => sub {join ', ', map { $self->_quote($_) } @$fields;},
+ SCALAR => sub {$self->_quote($fields)},
+ SCALARREF => sub {$$fields},
+ });
+ return join (' ', $self->_sqlcase(' returning'), $f);
+}
+
sub _insert_HASHREF { # explicit list of fields and then values
my ($self, $data) = @_;
More information about the Bast-commits
mailing list