From: Matt S Trout Date: Sat, 13 Apr 2019 02:19:07 +0000 (+0000) Subject: values clause X-Git-Tag: v1.90_01~227 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9352ece884deea1cb18e33ad34db870b01443389;p=dbsrgits%2FSQL-Abstract.git values clause --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index a2b474d..6025daf 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;