From: Rafael Kitover Date: Fri, 22 May 2009 13:50:45 +0000 (+0000) Subject: ::Replicated -- check for master rebless and reapply role if necessary X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0ce2d0d584bda471de28f1deec96abcd6254cc3f;p=dbsrgits%2FDBIx-Class-Historic.git ::Replicated -- check for master rebless and reapply role if necessary --- diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index 0dc50d7..259cdc5 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -324,6 +324,8 @@ C, C, C and C. around connect_info => sub { my ($next, $self, $info, @extra) = @_; + my $wantarray = wantarray; + my %opts; for my $arg (@$info) { next unless (reftype($arg)||'') eq 'HASH'; @@ -357,7 +359,19 @@ around connect_info => sub { $self->_master_connect_info_opts(\%opts); - $self->$next($info, @extra); + my (@res, $res); + if ($wantarray) { + @res = $self->$next($info, @extra); + } else { + $res = $self->$next($info, @extra); + } + + # May have to reapply role if master will be reblessed to a more specific + # driver. + $self->master->_determine_driver; + DBIx::Class::Storage::DBI::Replicated::WithDSN->meta->apply($self->master); + + $wantarray ? @res : $res; }; =head1 METHODS