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 )
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 {
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 =
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');