From: Dagfinn Ilmari Mannsåker Date: Fri, 17 Nov 2017 15:31:04 +0000 (+0000) Subject: Allow specifying columns for insert X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Finsert-columns;p=dbsrgits%2FSQL-Abstract.git Allow specifying columns for insert --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index eb048d0..3c80902 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -214,6 +214,10 @@ sub insert { my $data = shift || return; my $options = shift; + if (my $cols = $options->{columns}) { + $table_sql .= '('.join(', ', map $self->_quote($_), @$cols).')'; + } + my $method = $self->_METHOD_FOR_refkind("_insert", $data); my ($sql, @bind) = $self->$method($data); $sql = join " ", $self->_sqlcase('insert into'), $table, $sql;