use IO::File;
use Scalar::Util 'blessed';
-__PACKAGE__->mk_group_accessors(
- 'simple' =>
- qw/_connect_info _dbh _sql_maker _sql_maker_opts _conn_pid _conn_tid
- disable_sth_caching cursor on_connect_do transaction_depth/
+__PACKAGE__->mk_group_accessors('simple' =>
+ qw/_connect_info _dbi_connect_info _dbh _sql_maker _sql_maker_opts
+ _conn_pid _conn_tid disable_sth_caching cursor on_connect_do
+ transaction_depth/
);
BEGIN {
# the new set of options
$self->_sql_maker(undef);
$self->_sql_maker_opts({});
+ $self->_connect_info($info_arg);
- my $info = [ @$info_arg ]; # copy because we can alter it
- my $last_info = $info->[-1];
+ my $dbi_info = [@$info_arg]; # copy for DBI
+ my $last_info = $dbi_info->[-1];
if(ref $last_info eq 'HASH') {
for my $storage_opt (qw/on_connect_do disable_sth_caching/) {
if(my $value = delete $last_info->{$storage_opt}) {
}
# Get rid of any trailing empty hashref
- pop(@$info) if !keys %$last_info;
+ pop(@$dbi_info) if !keys %$last_info;
}
- if(ref $info->[0] ne 'CODE') {
+ $self->_dbi_connect_info($dbi_info);
+
+ if(ref $dbi_info->[0] ne 'CODE') {
# Extend to 3 arguments with undefs, if necessary
- while(scalar(@$info) < 3) { push(@$info, undef) }
+ while(scalar(@$dbi_info) < 3) { push(@$dbi_info, undef) }
# Complain if 4th argument is defined and is not a HASH
- if(defined $info->[3] && ref $info->[3] ne 'HASH') {
+ if(defined $dbi_info->[3] && ref $dbi_info->[3] ne 'HASH') {
warn "4th argument of DBI connect info is defined "
. " but is not a hashref!";
}
# Set AutoCommit to 1 if not specified manually
else {
- $info->[3] ||= {};
- if(!defined $info->[3]->{AutoCommit}) {
- $info->[3]->{AutoCommit} = 1;
+ $dbi_info->[3] ||= {};
+ if(!defined $dbi_info->[3]->{AutoCommit}) {
+ $dbi_info->[3]->{AutoCommit} = 1;
}
}
}
- $self->_connect_info($info);
+ $self->_connect_info;
}
=head2 on_connect_do
sub _populate_dbh {
my ($self) = @_;
- my @info = @{$self->_connect_info || []};
+ my @info = @{$self->_dbi_connect_info || []};
$self->_dbh($self->_connect(@info));
# Always set the transaction depth on connect, since