From: Matt S Trout Date: Sat, 13 Apr 2019 02:19:07 +0000 (+0000) Subject: values clause X-Git-Tag: v2.000000~3^2~248 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8a42cc74e0d64d9fcf8e8fd29c01664237cab757;p=dbsrgits%2FSQL-Abstract.git values clause --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 74d5446..1220d85 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -224,7 +224,7 @@ sub new { }; $opt{render} = { - (map +($_, "_render_$_"), qw(op func bind ident literal row)), + (map +($_, "_render_$_"), qw(op func bind ident literal row values)), %{$opt{render}||{}} }; @@ -271,8 +271,7 @@ sub insert { my @parts = ([ $self->_sqlcase('insert into').' '.$table ]); push @parts, [ $self->render_aqt($f_aqt) ] if $f_aqt; - push @parts, [ $self->render_aqt($v_aqt) ]; - $parts[-1][0] =~ s/^/VALUES /; + push @parts, [ $self->render_aqt({ -values => $v_aqt }) ]; if ($options->{returning}) { push @parts, [ $self->_insert_returning($options) ]; @@ -1084,6 +1083,16 @@ sub _render_row { return "($sql)", @bind; } +sub _render_values { + my ($self, $values) = @_; + my ($sql, @bind) = $self->_join_parts( + ', ', + map [ $self->render_aqt($_) ], + ref($values) eq 'ARRAY' ? @$values : $values + ); + return $self->_sqlcase('values ').$sql, @bind; +} + sub _render_func { my ($self, $rest) = @_; my ($func, @args) = @$rest;