From: Brandon L. Black Date: Mon, 14 May 2007 22:59:07 +0000 (+0000) Subject: default AutoCommit to 1 if not explicitly set, and stop warning about it X-Git-Tag: v0.08010~150^2~65 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2bc2ddc7025ff7123e2a31f367c608ae68e104b6;p=dbsrgits%2FDBIx-Class.git default AutoCommit to 1 if not explicitly set, and stop warning about it --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 33adf88..860cc36 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -335,8 +335,9 @@ a connected database handle. Please note that the L docs recommend that you always explicitly set C to either C<0> or C<1>. L further recommends that it be set to C<1>, and that you perform transactions via our L -method. L will emit a warning if you fail to explicitly -set C one way or the other. See below for more details. +method. L 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 will look there for several @@ -482,15 +483,23 @@ sub connect_info { 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}; + # Extend to 3 arguments with undefs, if necessary + while(scalar(@$info) < 3) { push(@$info, undef) } + + # Complain if 4th argument is defined and is not a HASH + if(defined $info->[3] && ref $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; + } + } } $self->_connect_info($info);