From: Peter Rabbitson Date: Sun, 31 Jul 2011 20:47:23 +0000 (+0200) Subject: This atrocity will be removed from sqla, do not use here either X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e8885a53b047e70baa425a6ed631cd5f97bf2195;p=dbsrgits%2FDBIx-Class-Historic.git This atrocity will be removed from sqla, do not use here either --- diff --git a/lib/DBIx/Class/SQLMaker.pm b/lib/DBIx/Class/SQLMaker.pm index c4bd627..fd42594 100644 --- a/lib/DBIx/Class/SQLMaker.pm +++ b/lib/DBIx/Class/SQLMaker.pm @@ -441,15 +441,18 @@ sub _gen_from_blocks { sub _from_chunk_to_sql { my ($self, $fromspec) = @_; - return join (' ', $self->_SWITCH_refkind($fromspec, { - SCALARREF => sub { + return join (' ', do { + if (! ref $fromspec) { + $self->_quote($fromspec); + } + elsif (ref $fromspec eq 'SCALAR') { $$fromspec; - }, - ARRAYREFREF => sub { + } + elsif (ref $fromspec eq 'REF' and ref $$fromspec eq 'ARRAY') { push @{$self->{from_bind}}, @{$$fromspec}[1..$#$$fromspec]; $$fromspec->[0]; - }, - HASHREF => sub { + } + elsif (ref $fromspec eq 'HASH') { my ($as, $table, $toomuch) = ( map { $_ => $fromspec->{$_} } ( grep { $_ !~ /^\-/ } keys %$fromspec ) @@ -459,11 +462,11 @@ sub _from_chunk_to_sql { if defined $toomuch; ($self->_from_chunk_to_sql($table), $self->_quote($as) ); - }, - SCALAR => sub { - $self->_quote($fromspec); - }, - })); + } + else { + $self->throw_exception('Unsupported from refkind: ' . ref $fromspec ); + } + }); } sub _join_condition { diff --git a/lib/DBIx/Class/SQLMaker/Oracle.pm b/lib/DBIx/Class/SQLMaker/Oracle.pm index d088192..d144113 100644 --- a/lib/DBIx/Class/SQLMaker/Oracle.pm +++ b/lib/DBIx/Class/SQLMaker/Oracle.pm @@ -75,13 +75,13 @@ sub _order_siblings_by { my ( @sql, @bind ); for my $c ( $self->_order_by_chunks($arg) ) { - $self->_SWITCH_refkind( - $c, - { - SCALAR => sub { push @sql, $c }, - ARRAYREF => sub { push @sql, shift @$c; push @bind, @$c }, - } - ); + if (ref $c) { + push @sql, shift @$c; + push @bind, @$c; + } + else { + push @sql, $c; + } } my $sql = @@ -210,20 +210,29 @@ sub _insert_returning { 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 ($f_list, @f_names) = do { + if (! ref $f) { + ( + $self->_quote($f), + $f, + ) + } + elsif (ref $f eq 'ARRAY') { + ( + (join ', ', map { $self->_quote($_) } @$f), + @$f, + ) + } + elsif (ref $f eq 'SCALAR') { + ( + $$f, + $$f, + ) + } + else { + $self->throw_exception("Unsupported INSERT RETURNING option $f"); + } + }; my $rc_ref = $options->{returning_container} or $self->throw_exception('No returning container supplied for IR values');