Add all database connections via DBICTest::Schema to the leaktrace pool
[dbsrgits/DBIx-Class.git] / t / 73oracle_hq.t
index 07c1f40..538fdf8 100644 (file)
@@ -3,7 +3,7 @@ use warnings;
 
 use Test::Exception;
 use Test::More;
-
+use DBIx::Class::Optional::Dependencies ();
 use lib qw(t/lib);
 use DBIC::SqlMakerTest;
 
@@ -15,14 +15,14 @@ $ENV{NLS_SORT} = "BINARY";
 $ENV{NLS_COMP} = "BINARY";
 $ENV{NLS_LANG} = "AMERICAN";
 
-plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_oracle')
-  unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_oracle');
-
 my ($dsn,  $user,  $pass)  = @ENV{map { "DBICTEST_ORA_${_}" }  qw/DSN USER PASS/};
 
 plan skip_all => 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test.'
  unless ($dsn && $user && $pass);
 
+plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_oracle')
+  unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_oracle');
+
 use DBICTest::Schema::Artist;
 BEGIN {
   DBICTest::Schema::Artist->add_column('parentid');
@@ -316,7 +316,7 @@ do_creates($dbh);
     my $rs = $schema->resultset('Artist')->search({}, {
       start_with => { name => 'root' },
       connect_by => { parentid => { -prior => { -ident => 'artistid' } } },
-      order_by => { -asc => 'name' },
+      order_by => [ { -asc => 'name' }, {  -desc => 'artistid' } ],
       rows => 2,
     });
 
@@ -329,7 +329,7 @@ do_creates($dbh);
               FROM artist me
             START WITH name = ?
             CONNECT BY parentid = PRIOR artistid
-            ORDER BY name ASC
+            ORDER BY name ASC, artistid DESC
           ) me
         WHERE ROWNUM <= ?
       )',
@@ -362,7 +362,8 @@ do_creates($dbh);
       )',
       [
         [ { 'sqlt_datatype' => 'varchar', 'dbic_colname' => 'name', 'sqlt_size' => 100 }
-            => 'root'], [ $ROWS => 2 ] ,
+            => 'root'],
+        [ $ROWS => 2 ],
       ],
     );
 
@@ -552,13 +553,15 @@ sub do_creates {
 
 # clean up our mess
 END {
-  eval {
-    my $dbh = $schema->storage->dbh;
-    $dbh->do("DROP SEQUENCE artist_pk_seq");
-    $dbh->do("DROP SEQUENCE cd_seq");
-    $dbh->do("DROP SEQUENCE track_seq");
-    $dbh->do("DROP TABLE artist");
-    $dbh->do("DROP TABLE track");
-    $dbh->do("DROP TABLE cd");
+  if ($schema and my $dbh = $schema->storage->dbh) {
+    eval { $dbh->do($_) } for (
+      'DROP SEQUENCE artist_pk_seq',
+      'DROP SEQUENCE cd_seq',
+      'DROP SEQUENCE track_seq',
+      'DROP TABLE artist',
+      'DROP TABLE track',
+      'DROP TABLE cd',
+    );
   };
+  undef $schema;
 }