X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSQLMaker%2FOracle.pm;h=400fc63fbb3387078a507a4c9db7ef749b3d079b;hb=9c1700e39e6ee002d9294c0d988882d1f0d7d86f;hp=0a773e7ad063a65666268182e63fa157ed8e03b6;hpb=d5dedbd62928f65a9071b4d9b6d56c6b663a073b;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/SQLMaker/Oracle.pm b/lib/DBIx/Class/SQLMaker/Oracle.pm index 0a773e7..400fc63 100644 --- a/lib/DBIx/Class/SQLMaker/Oracle.pm +++ b/lib/DBIx/Class/SQLMaker/Oracle.pm @@ -6,6 +6,13 @@ use strict; use base qw( DBIx::Class::SQLMaker ); use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/; +use namespace::clean; + +BEGIN { + use DBIx::Class::Optional::Dependencies; + croak('The following extra modules are required for Oracle-based Storages ' . DBIx::Class::Optional::Dependencies->req_missing_for ('id_shortener') ) + unless DBIx::Class::Optional::Dependencies->req_ok_for ('id_shortener'); +} sub new { my $self = shift; @@ -20,7 +27,7 @@ sub new { sub _assemble_binds { my $self = shift; - return map { @{ (delete $self->{"${_}_bind"}) || [] } } (qw/from where oracle_connect_by having order/); + return map { @{ (delete $self->{"${_}_bind"}) || [] } } (qw/select from where oracle_connect_by group having order/); } @@ -183,4 +190,48 @@ sub _unqualify_colname { return $self->_shorten_identifier($self->next::method($fqcn)); } +# +# Oracle has a different INSERT...RETURNING syntax +# + +sub _insert_returning { + my ($self, $options) = @_; + + my $f = $options->{returning}; + + my ($f_list, @f_names) = $self->_SWITCH_refkind($f, { + ARRAYREF => sub { + (join ', ', map { $self->_quote($_) } @$f), + @$f + }, + SCALAR => sub { + $self->_quote($f), + $f, + }, + SCALARREF => sub { + $$f, + $$f, + }, + }); + + my $rc_ref = $options->{returning_container} + or croak ('No returning container supplied for IR values'); + + @$rc_ref = (undef) x @f_names; + + return ( + ( join (' ', + $self->_sqlcase(' returning'), + $f_list, + $self->_sqlcase('into'), + join (', ', ('?') x @f_names ), + )), + map { + $self->{bindtype} eq 'columns' + ? [ $f_names[$_] => \$rc_ref->[$_] ] + : \$rc_ref->[$_] + } (0 .. $#f_names), + ); +} + 1;