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

rbo at dev.catalyst.perl.org rbo at dev.catalyst.perl.org
Mon Mar 15 17:25:56 GMT 2010


Author: rbo
Date: 2010-03-15 17:25:56 +0000 (Mon, 15 Mar 2010)
New Revision: 9012

Modified:
   DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/t/73oracle.t
Log:
fixed hierarchical query tests, not all pass yet


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-15 17:24:47 UTC (rev 9011)
+++ DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/t/73oracle.t	2010-03-15 17:25:56 UTC (rev 9012)
@@ -506,7 +506,7 @@
             LEFT JOIN cd cds ON cds.artist = me.artistid
           WHERE ( cds.title LIKE ? )
           START WITH me.name = ?
-          CONNECT BY parentid = prior artistid
+          CONNECT BY parentid = PRIOR( artistid )
         )',
         [ [ 'cds.title' => '%cd' ], [ 'me.name' => 'root' ] ],
       );
@@ -553,25 +553,57 @@
 
       is_same_sql_bind (
         $rs->as_query,
-        '(
-          need to fill in correct sql
+        '( 
+            SELECT * FROM (
+                  SELECT A.*, ROWNUM r FROM (
+                      SELECT 
+                          me.artistid AS col1,
+                          me.name AS col2,
+                          me.rank AS col3,
+                          me.charfield AS col4,
+                          me.parentid AS col5 
+                      FROM artist me 
+                      START WITH name = ? 
+                      CONNECT BY artistid = PRIOR( parentid )
+                      ORDER BY name DESC
+                  ) A
+                  WHERE ROWNUM < 3
+              ) B
+              WHERE r >= 1 
         )',
-        [],
+        [ [ name => 'greatgrandchild' ] ],
       );
 
       is_deeply (
         [ $rs->get_column ('name')->all ],
-        [ qw/grandchild child1/ ],
+        [qw/root greatgrandchild/],
         'LIMIT a Connect By query - correct names'
       );
 
-
+      # TODO: 
+      # prints "START WITH name = ? 
+      # CONNECT BY artistid = PRIOR( parentid )"
+      # after count_subq, 
+      # I will fix this later...
+      # 
       is_same_sql_bind (
         $rs->count_rs->as_query,
-        '(
-          need to fill in correct sql
+        '( 
+            SELECT COUNT( * ) FROM (
+                SELECT * FROM (
+                    SELECT A.*, ROWNUM r FROM (
+                        SELECT 
+                            me.artistid AS col1 
+                        FROM artist me 
+                        START WITH name = ? 
+                        CONNECT BY artistid = PRIOR( parentid ) 
+                    ) A
+                    WHERE ROWNUM < 3
+                ) B
+                WHERE r >= 1
+            ) count_subq 
         )',
-        [],
+        [ [ name => 'greatgrandchild' ] ],
       );
 
       is( $rs->count, 2, 'Connect By; LIMIT count ok' );




More information about the Bast-commits mailing list