[Bast-commits] r9069 - DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/t

rbo at dev.catalyst.perl.org rbo at dev.catalyst.perl.org
Sat Mar 27 18:10:26 GMT 2010


Author: rbo
Date: 2010-03-27 18:10:26 +0000 (Sat, 27 Mar 2010)
New Revision: 9069

Modified:
   DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/t/73oracle.t
Log:
Test with the correct arrangement of the tree.
(oracle hierarchical queries)



Modified: DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/t/73oracle.t
===================================================================
--- DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/t/73oracle.t	2010-03-27 13:51:34 UTC (rev 9068)
+++ DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/t/73oracle.t	2010-03-27 18:10:26 UTC (rev 9069)
@@ -444,8 +444,8 @@
     # get the root node
     {
       my $rs = $schema->resultset('Artist')->search({ parentid => undef }, {
-        start_with => { name => 'greatgrandchild' },
-        connect_by => { artistid => { -prior => \ 'parentid' } },
+        start_with => { name => 'root' },
+        connect_by => { parentid => { -prior => \ 'artistid' } },
       });
 
       is_same_sql_bind (
@@ -455,9 +455,9 @@
             FROM artist me
           WHERE ( parentid IS NULL )
           START WITH name = ?
-          CONNECT BY artistid = PRIOR( parentid )
+          CONNECT BY parentid = PRIOR( artistid )
         )',
-        [ [ name => 'greatgrandchild'] ],
+        [ [ name => 'root'] ],
       );
 
       is_deeply(
@@ -517,9 +517,9 @@
     # combine a connect by with order_by
     {
       my $rs = $schema->resultset('Artist')->search({}, {
-        start_with => { name => 'greatgrandchild' },
-        connect_by => { artistid => { -prior => \ 'parentid' } },
-        order_by => { -asc => 'name' },
+        start_with => { name => 'root' },
+        connect_by => { parentid => { -prior => \ 'artistid' } },
+        order_by => { -asc => [ 'LEVEL', 'name' ] },
       });
 
       is_same_sql_bind (
@@ -528,15 +528,15 @@
           SELECT me.artistid, me.name, me.rank, me.charfield, me.parentid
             FROM artist me
           START WITH name = ?
-          CONNECT BY artistid = PRIOR( parentid )
-          ORDER BY name ASC
+          CONNECT BY parentid = PRIOR( artistid )
+          ORDER BY LEVEL ASC, name ASC
         )',
-        [ [ name => 'greatgrandchild' ] ],
+        [ [ name => 'root' ] ],
       );
 
       is_deeply (
         [ $rs->get_column ('name')->all ],
-        [ qw/child1 grandchild greatgrandchild root/ ],
+        [ qw/root child1 child2 grandchild greatgrandchild/ ],
         'Connect By with a order_by - result name ok'
       );
     }
@@ -545,9 +545,9 @@
     # limit a connect by
     {
       my $rs = $schema->resultset('Artist')->search({}, {
-        start_with => { name => 'greatgrandchild' },
-        connect_by => { artistid => { -prior => \ 'parentid' } },
-        order_by => { -desc => 'name' },
+        start_with => { name => 'root' },
+        connect_by => { parentid => { -prior => \ 'artistid' } },
+        order_by => { -asc => 'name' },
         rows => 2,
       });
 
@@ -564,19 +564,19 @@
                           me.parentid AS col5 
                       FROM artist me 
                       START WITH name = ? 
-                      CONNECT BY artistid = PRIOR( parentid )
-                      ORDER BY name DESC
+                      CONNECT BY parentid = PRIOR( artistid )
+                      ORDER BY name ASC
                   ) A
                   WHERE ROWNUM < 3
               ) B
               WHERE r >= 1 
         )',
-        [ [ name => 'greatgrandchild' ] ],
+        [ [ name => 'root' ] ],
       );
 
       is_deeply (
         [ $rs->get_column ('name')->all ],
-        [qw/root greatgrandchild/],
+        [qw/child1 child2/],
         'LIMIT a Connect By query - correct names'
       );
 




More information about the Bast-commits mailing list