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 {
recommend that you always explicitly set C<AutoCommit> to either
C<0> or C<1>. L<DBIx::Class> further recommends that it be set
to C<1>, and that you perform transactions via our L</txn_do>
-method. L<DBIx::Class> will emit a warning if you fail to explicitly
-set C<AutoCommit> one way or the other. See below for more details.
+method. L<DBIx::Class> will set it to C<1> if you do not do explicitly
+set it to zero. This is the default for most DBDs. See below for more
+details.
In either case, if the final argument in your connect_info happens
to be a hashref, C<connect_info> will look there for several
# the new set of options
$self->_sql_maker(undef);
$self->_sql_maker_opts({});
+ $self->_connect_info([@$info_arg]); # copy for _connect_info
- my $info = [ @$info_arg ]; # copy because we can alter it
- my $last_info = $info->[-1];
+ my $dbi_info = [@$info_arg]; # copy for _dbi_connect_info
+
+ 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;
- }
-
- # Now check the (possibly new) final argument for AutoCommit,
- # but not in the coderef case, obviously.
- if(ref $info->[0] ne 'CODE') {
- $last_info = $info->[3];
- warn "You *really* should explicitly set AutoCommit "
- . "(preferably to 1) in your db connect info"
- if !$last_info
- || ref $last_info ne 'HASH'
- || !defined $last_info->{AutoCommit};
+ pop(@$dbi_info) if !keys %$last_info;
}
+ $self->_dbi_connect_info($dbi_info);
- $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
next if($_ =~ /^COMMIT/m);
next if $_ =~ /^\s+$/; # skip whitespace only
$self->debugobj->query_start($_) if $self->debug;
- $self->dbh->do($_) or warn "SQL was:\n $_"; # XXX exceptions?
+ $self->dbh->do($_) or warn $self->dbh->errstr, "\nSQL was:\n $_"; # XXX throw_exception?
$self->debugobj->query_end($_) if $self->debug;
}
}