Test with explicitly readonly 'replicants' under DBICTEST_VIA_REPLICATED
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / BaseSchema.pm
index 111b84b..4fa2f20 100644 (file)
@@ -224,7 +224,7 @@ sub connection {
       and
     ref($_[0]) ne 'CODE'
       and
-    ($_[0]||'') !~ /^ (?i:dbi) \: SQLite \: (?: dbname\= )? (?: \:memory\: | t [\/\\] var [\/\\] DBIxClass\-) /x
+    ($_[0]||'') !~ /^ (?i:dbi) \: SQLite (?: \: | \W ) .*? (?: dbname\= )? (?: \:memory\: | t [\/\\] var [\/\\] DBIxClass\-) /x
   ) {
 
     my $locktype;
@@ -242,7 +242,12 @@ sub connection {
       # this will either give us an undef $locktype or will determine things
       # properly with a default ( possibly connecting in the process )
       eval {
-        my $s = ref($self)->connect(@{$self->storage->connect_info})->storage;
+        my $cur_storage = $self->storage;
+
+        $cur_storage = $cur_storage->master
+          if $cur_storage->isa('DBIx::Class::Storage::DBI::Replicated');
+
+        my $s = ref($self)->connect(@{$cur_storage->connect_info})->storage;
 
         $locktype = $s->sqlt_type || 'generic';