From: Ash Berlin Date: Sun, 16 May 2010 10:28:13 +0000 (+0000) Subject: Fix how Schema::Versioned gets connection attributes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8012b15cd056286d84a619882301970c6c3cf3bb;p=dbsrgits%2FDBIx-Class-Historic.git Fix how Schema::Versioned gets connection attributes --- diff --git a/Changes b/Changes index a6ba126..120be79 100644 --- a/Changes +++ b/Changes @@ -26,6 +26,7 @@ Revision history for DBIx::Class - update() on row not in_storage no longer throws an exception if there are no dirty columns to update (fixes cascaded update annoyances) + - Update Schema::Versioned to respect hashref style of connection_info 0.08121 2010-04-11 18:43:00 (UTC) - Support for Firebird RDBMS with DBD::InterBase and ODBC diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index aa4f702..d192d21 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -558,24 +558,25 @@ To avoid the checks on connect, set the environment var DBIC_NO_VERSION_CHECK or sub connection { my $self = shift; $self->next::method(@_); - $self->_on_connect($_[3]); + $self->_on_connect(); return $self; } sub _on_connect { - my ($self, $args) = @_; + my ($self) = @_; - $args = {} unless $args; + my $info = $self->storage->connect_info; + my $args = $info->[-1]; - $self->{vschema} = DBIx::Class::Version->connect(@{$self->storage->connect_info()}); + $self->{vschema} = DBIx::Class::Version->connect(@$info); my $vtable = $self->{vschema}->resultset('Table'); # useful when connecting from scripts etc return if ($args->{ignore_version} || ($ENV{DBIC_NO_VERSION_CHECK} && !exists $args->{ignore_version})); # check for legacy versions table and move to new if exists - my $vschema_compat = DBIx::Class::VersionCompat->connect(@{$self->storage->connect_info()}); + my $vschema_compat = DBIx::Class::VersionCompat->connect(@$info); unless ($self->_source_exists($vtable)) { my $vtable_compat = $vschema_compat->resultset('TableCompat'); if ($self->_source_exists($vtable_compat)) { diff --git a/t/94versioning.t b/t/94versioning.t index b73d612..ad4657e 100644 --- a/t/94versioning.t +++ b/t/94versioning.t @@ -245,6 +245,33 @@ system( qq($^X -pi -e "s/ALTER/-- this is a comment\nALTER/" $fn->{trans_v23};) is($schema_v2->get_db_version(), '3.0', 'Fast deploy/upgrade'); }; +# Check that it Schema::Versioned deals with new/all forms of connect arguments. +{ + my $get_db_version_run = 0; + + no warnings qw/once redefine/; + local *DBIx::Class::Schema::Versioned::get_db_version = sub { + $get_db_version_run = 1; + return $_[0]->schema_version; + }; + + # Make sure the env var isn't whats triggering it + local $ENV{DBIC_NO_VERSION_CHECK} = 0; + + DBICVersion::Schema->connect({ + dsn => $dsn, + user => $user, + pass => $pass, + ignore_version => 1 + }); + + ok($get_db_version_run == 0, "attributes pulled from hashref connect_info"); + $get_db_version_run = 0; + + DBICVersion::Schema->connect( $dsn, $user, $pass, { ignore_version => 1 } ); + ok($get_db_version_run == 0, "attributes pulled from list connect_info"); +} + unless ($ENV{DBICTEST_KEEP_VERSIONING_DDL}) { unlink $_ for (values %$fn); }