From: Matt S Trout <mst@shadowcat.co.uk>
Date: Tue, 18 Sep 2018 01:24:08 +0000 (+0000)
Subject: RETURNING using render/expand
X-Git-Tag: v2.000000~3^2~444
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2c05664d11c07292b015a66020235ef2bc17dfc2;p=dbsrgits%2FSQL-Abstract.git

RETURNING using render/expand
---

diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm
index dbd9943..96b170f 100644
--- a/lib/SQL/Abstract.pm
+++ b/lib/SQL/Abstract.pm
@@ -224,12 +224,12 @@ sub _returning {
 
   my $f = $options->{returning};
 
-  my $fieldlist = $self->_SWITCH_refkind($f, {
-    ARRAYREF     => sub {join ', ', map { $self->_quote($_) } @$f;},
-    SCALAR       => sub {$self->_quote($f)},
-    SCALARREF    => sub {$$f},
-  });
-  return $self->_sqlcase(' returning ') . $fieldlist;
+  my ($sql, @bind) = $self->_render_expr(
+    $self->_expand_maybe_list_expr($f, undef, -ident)
+  );
+  return wantarray
+    ? $self->_sqlcase(' returning ') . $sql
+    : ($self->_sqlcase(' returning ').$sql, @bind);
 }
 
 sub _insert_HASHREF { # explicit list of fields and then values