From: Matt S Trout Date: Sun, 17 Mar 2013 22:31:29 +0000 (+0000) Subject: RETURNING ... INTO works for non-literal column names X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2166cd90e5924d0e1da2a00f0a668c9c0c6b830a;p=dbsrgits%2FDBIx-Class-Historic.git RETURNING ... INTO works for non-literal column names --- diff --git a/lib/DBIx/Class/SQLMaker/Converter/Oracle.pm b/lib/DBIx/Class/SQLMaker/Converter/Oracle.pm index e636d6d..de3829d 100644 --- a/lib/DBIx/Class/SQLMaker/Converter/Oracle.pm +++ b/lib/DBIx/Class/SQLMaker/Converter/Oracle.pm @@ -1,5 +1,6 @@ package DBIx::Class::SQLMaker::Converter::Oracle; +use Data::Query::ExprHelpers; use Moo; extends 'DBIx::Class::SQLMaker::Converter'; @@ -27,4 +28,26 @@ around _apply_to_dq => sub { } }; +around _insert_to_dq => sub { + my ($orig, $self) = (shift, shift); + my (undef, undef, $options) = @_; + my $dq = $self->$orig(@_); + my $ret_count = @{$dq->{returning}}; + @{$options->{returning_container}} = (undef) x $ret_count; + my $into = [ + map { + my $r_dq = $dq->{returning}[$_]; + no warnings 'once'; +::Dwarn($r_dq); + local $SQL::Abstract::Converter::Cur_Col_Meta = ( + is_Identifier($r_dq) + ? join('.', @{$r_dq->{elements}}) + : undef + ); + $self->_value_to_dq(\($options->{returning_container}[$_])); + } 0..$ret_count-1 + ]; + +{ %$dq, 'Data::Query::Renderer::SQL::Dialect::ReturnInto.into' => $into }; +}; + 1; diff --git a/lib/DBIx/Class/SQLMaker/Oracle.pm b/lib/DBIx/Class/SQLMaker/Oracle.pm index 9791dcd..afc6ad3 100644 --- a/lib/DBIx/Class/SQLMaker/Oracle.pm +++ b/lib/DBIx/Class/SQLMaker/Oracle.pm @@ -20,6 +20,7 @@ around _build_renderer_roles => sub { my ($orig, $self) = (shift, shift); ( 'Data::Query::Renderer::SQL::Extension::ConnectBy', + 'Data::Query::Renderer::SQL::Dialect::ReturnInto', $self->$orig(@_), ); };