X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2Fdbixcsl_common_tests.pm;h=3e67dac504c1300145ba6b9901d66a413cbf8449;hb=c0084472a2f4515cbbd3970773b7d52ff20bcc45;hp=92583bb7c0e4b753381f857d5aaea34f7fca4707;hpb=ca12f6c9ea89282afe711aa4ec543630feb4a1ae;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index 92583bb..3e67dac 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -832,17 +832,25 @@ sub check_no_duplicate_unique_constraints { sub dbconnect { my ($self, $complain) = @_; - my $dbh = DBI->connect( - $self->{dsn}, $self->{user}, - $self->{password}, - { - RaiseError => $complain, - PrintError => $complain, - AutoCommit => 1, - } - ); + require DBIx::Class::Storage::DBI; + my $storage = DBIx::Class::Storage::DBI->new; + + $complain = defined $complain ? $complain : 1; + + $storage->connect_info([ + @{ $self }{qw/dsn user password/}, + { + unsafe => 1, + RaiseError => $complain, + ShowErrorStatement => $complain, + PrintError => 0, + }, + ]); + + my $dbh = eval { $storage->dbh }; + die "Failed to connect to database: $@" if !$dbh; - die "Failed to connect to database: $DBI::errstr" if !$dbh; + $self->{storage} = $storage; # storage DESTROY disconnects return $dbh; }