if (defined $_[0]->{order_by}) {
$ret .= $self->SUPER::_order_by($_[0]->{order_by});
}
+ } elsif(ref $_[0] eq 'SCALAR') {
+ $ret = $self->_sqlcase(' order by ').${ $_[0] };
} else {
$ret = $self->SUPER::_order_by(@_);
}
sub _connect {
my ($self, @info) = @_;
+ my ($old_connect_via, $dbh);
+
if ($INC{'Apache/DBI.pm'} && $ENV{MOD_PERL}) {
- my $old_connect_via = $DBI::connect_via;
+ $old_connect_via = $DBI::connect_via;
$DBI::connect_via = 'connect';
- my $dbh = DBI->connect(@info);
- $DBI::connect_via = $old_connect_via;
- return $dbh;
}
- my $dbh = DBI->connect(@info);
+ if(ref $info[0] eq 'CODE') {
+ $dbh = &{$info[0]};
+ }
+ else {
+ $dbh = DBI->connect(@info);
+ }
+
+ $DBI::connect_via = $old_connect_via if $old_connect_via;
+
$self->throw_exception("DBI Connection failed: $DBI::errstr")
unless $dbh;
+
$dbh;
}
@bind = map { ref $_ ? ''.$_ : $_ } @bind; # stringify args
my $rv;
if ($sth) {
- $rv = $sth->execute(@bind);
+ $rv = $sth->execute(@bind) or $self->throw_exception("Error executing '$sql': " . $sth->errstr);
} else {
$self->throw_exception("'$sql' did not generate a statement.");
}
}
-sub sqlt_type {
- my ($self) = @_;
- my $dsn = $self->connect_info->[0];
- $dsn =~ /^dbi:(.*?)\d*:/;
- return $1;
-}
+sub sqlt_type { shift->dbh->{Driver}->{Name} }
sub deployment_statements {
my ($self, $schema, $type) = @_;