Added documentation for from => $rs->as_query
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Replicated.pm
index 0dc50d7..259cdc5 100644 (file)
@@ -324,6 +324,8 @@ C<pool_type>, C<pool_args>, C<balancer_type> and C<balancer_args>.
 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