Fixed count subquery from disabled test case
[dbsrgits/DBIx-Class.git] / t / 73oracle.t
index ca55487..d6e90e3 100644 (file)
@@ -405,7 +405,7 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
           SELECT me.artistid, me.name, me.rank, me.charfield, me.parentid
             FROM artist me
           START WITH name = ?
-          CONNECT BY parentid = PRIOR( artistid )
+          CONNECT BY parentid = PRIOR artistid 
         )',
         [ [ name => 'root'] ],
       );
@@ -422,7 +422,7 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
           SELECT COUNT( * )
             FROM artist me
           START WITH name = ?
-          CONNECT BY parentid = PRIOR( artistid )
+          CONNECT BY parentid = PRIOR artistid 
         )',
         [ [ name => 'root'] ],
       );
@@ -444,7 +444,7 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
           SELECT me.artistid, me.name, me.rank, me.charfield, me.parentid
             FROM artist me
           START WITH name = ?
-          CONNECT BY parentid = PRIOR( artistid )
+          CONNECT BY parentid = PRIOR artistid 
           ORDER SIBLINGS BY name DESC
         )',
         [ [ name => 'root'] ],
@@ -471,7 +471,7 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
             FROM artist me
           WHERE ( parentid IS NULL )
           START WITH name = ?
-          CONNECT BY parentid = PRIOR( artistid )
+          CONNECT BY parentid = PRIOR artistid 
         )',
         [ [ name => 'root'] ],
       );
@@ -502,7 +502,7 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
             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' ] ],
       );
@@ -522,7 +522,7 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
             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' ] ],
       );
@@ -544,7 +544,7 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
           SELECT me.artistid, me.name, me.rank, me.charfield, me.parentid
             FROM artist me
           START WITH name = ?
-          CONNECT BY parentid = PRIOR( artistid )
+          CONNECT BY parentid = PRIOR artistid 
           ORDER BY LEVEL ASC, name ASC
         )',
         [ [ name => 'root' ] ],
@@ -570,22 +570,21 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
       is_same_sql_bind (
         $rs->as_query,
         '( 
-            SELECT * FROM (
-                  SELECT A.*, ROWNUM r FROM (
+            SELECT artistid, name, rank, charfield, parentid FROM (
+                  SELECT artistid, name, rank, charfield, parentid, ROWNUM rownum__index FROM (
                       SELECT 
-                          me.artistid AS col1,
-                          me.name AS col2,
-                          me.rank AS col3,
-                          me.charfield AS col4,
-                          me.parentid AS col5 
+                          me.artistid,
+                          me.name,
+                          me.rank,
+                          me.charfield,
+                          me.parentid 
                       FROM artist me 
                       START WITH name = ? 
-                      CONNECT BY parentid = PRIOR( artistid )
-                      ORDER BY name ASC
-                  ) A
-                  WHERE ROWNUM < 3
-              ) B
-              WHERE r >= 1 
+                      CONNECT BY parentid = PRIOR artistid
+                      ORDER BY name ASC 
+                  ) me 
+            ) me
+            WHERE rownum__index BETWEEN 1 AND 2
         )',
         [ [ name => 'root' ] ],
       );
@@ -598,7 +597,7 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
 
       # TODO: 
       # prints "START WITH name = ? 
-      # CONNECT BY artistid = PRIOR( parentid )"
+      # CONNECT BY artistid = PRIOR parentid "
       # after count_subq, 
       # I will fix this later...
       # 
@@ -606,18 +605,17 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
       #   $rs->count_rs->as_query,
       #   '( 
       #       SELECT COUNT( * ) FROM (
-      #           SELECT * FROM (
-      #               SELECT A.*, ROWNUM r FROM (
+      #           SELECT artistid FROM (
+      #               SELECT artistid, ROWNUM rownum__index FROM (
       #                   SELECT 
-      #                       me.artistid AS col1 
+      #                       me.artistid
       #                   FROM artist me 
       #                   START WITH name = ? 
-      #                   CONNECT BY artistid = PRIOR( parentid ) 
-      #               ) A
-      #               WHERE ROWNUM < 3
-      #           ) B
-      #           WHERE r >= 1
-      #       ) count_subq 
+      #                   CONNECT BY artistid = PRIOR parentid 
+      #               ) me
+      #           ) me 
+      #           WHERE rownum__index BETWEEN 1 AND 2
+      #       ) me
       #   )',
       #   [ [ name => 'greatgrandchild' ] ],
       # );
@@ -632,7 +630,7 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
         connect_by => { parentid => { -prior => \ 'artistid' } },
       });
       eval { $rs->get_column ('name')->all };
-      if ( $@ =~ /ORA-01436/ ){ # ORA-01436:   CONNECT BY loop in user data
+      if ( $@ =~ /ORA-01436/ ){ # ORA-01436:  CONNECT BY loop in user data
         pass "connect by initify loop detection without nocycle";
       }else{
         fail "connect by initify loop detection without nocycle, not detected by oracle";
@@ -642,7 +640,7 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
     # select the whole cycle tree with nocylce
     {
       my $rs = $schema->resultset('Artist')->search({}, {
-        nocycle    => 1,
+        connect_by_nocycle    => 1,
         start_with => { name => 'cycle-root' },
         '+select'  => [ \ 'CONNECT_BY_ISCYCLE' ],
         connect_by => { parentid => { -prior => \ 'artistid' } },
@@ -654,7 +652,7 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
           SELECT me.artistid, me.name, me.rank, me.charfield, me.parentid, CONNECT_BY_ISCYCLE
             FROM artist me
           START WITH name = ?
-          CONNECT BY NOCYCLE parentid = PRIOR( artistid )
+          CONNECT BY NOCYCLE parentid = PRIOR artistid 
         )',
         [ [ name => 'cycle-root'] ],
       );
@@ -676,7 +674,7 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) {
           SELECT COUNT( * )
             FROM artist me
           START WITH name = ?
-          CONNECT BY NOCYCLE parentid = PRIOR( artistid )
+          CONNECT BY NOCYCLE parentid = PRIOR artistid 
         )',
         [ [ name => 'cycle-root'] ],
       );