Fix leak of $sth during populate() on perls < 5.10
[dbsrgits/DBIx-Class.git] / t / 52cycle.t
index b64be5c..d3d88d5 100644 (file)
@@ -27,12 +27,6 @@ my $weak;
   my $storage = $weak->{storage} = $s->storage;
   memory_cycle_ok($storage, 'No cycles in storage');
 
-  my $dbh = $weak->{dbh} = $s->storage->_get_dbh;
-  memory_cycle_ok($dbh, 'No cycles in DBI handle');
-
-  my $sqla = $weak->{sqla} = $s->storage->sql_maker;
-  memory_cycle_ok($sqla, 'No cycles in SQL maker');
-
   my $rs = $weak->{resultset} = $s->resultset ('Artist');
   memory_cycle_ok($rs, 'No cycles in resultset');
 
@@ -42,6 +36,16 @@ my $weak;
   my $row = $weak->{row} = $rs->first;
   memory_cycle_ok($row, 'No cycles in row');
 
+  my $sqla = $weak->{sqla} = $s->storage->sql_maker;
+  memory_cycle_ok($sqla, 'No cycles in SQL maker');
+
+  my $dbh = $weak->{dbh} = $s->storage->_get_dbh;
+  memory_cycle_ok($dbh, 'No cycles in DBI handle');
+
+  for (@{$dbh->{ChildHandles}}) {
+    $weak->{"$_"} = $_ if $_;
+  }
+
   weaken $_ for values %$weak;
   memory_cycle_ok($weak, 'No cycles in weak object collection');
 }