Make sure unaliased selectors and prefetch coexist peacefully
[dbsrgits/DBIx-Class.git] / t / search / select_chains_unbalanced.t
index d0facb8..d602605 100644 (file)
@@ -34,33 +34,30 @@ my @chain = (
     => [qw/cdid title foo bar/],
 
   {
-    '+select'   => [ 'genreid', $multicol_rs->as_query ],
-    '+as'       => [qw/genreid name rank/],
+    '+select'   => \'unaliased randomness',
   } => 'SELECT
           me.cdid,
           me.title,
           DISTINCT(foo, bar),
-          me.genreid,
-          (SELECT me.name, me.rank FROM artist me WHERE ( artistid 1 ))
+          unaliased randomness
         FROM cd me'
-    => [qw/cdid title foo bar genreid name rank/],
-
+    => [qw/cdid title foo bar/],
   {
-    '+select'   => { count => 'me.cdid', -as => 'cnt' },  # lack of 'as' infers from '-as'
-    '+columns'  => { len => { length => 'me.title' } },
+    '+select'   => [ 'genreid', $multicol_rs->as_query ],
+    '+as'       => [qw/genreid name rank/],
   } => 'SELECT
           me.cdid,
           me.title,
-          LENGTH( me.title ),
-          COUNT( me.cdid ) AS cnt,
           DISTINCT(foo, bar),
           me.genreid,
-          (SELECT me.name, me.rank FROM artist me WHERE ( artistid 1 ))
+          (SELECT me.name, me.rank FROM artist me WHERE ( artistid 1 )),
+          unaliased randomness
         FROM cd me'
-    => [qw/cdid title len cnt foo bar genreid name rank/],
+    => [qw/cdid title foo bar genreid name rank/],
 
   {
-    '+select'   => \'unaliased randomness',
+    '+select'   => { count => 'me.cdid', -as => 'cnt' },  # lack of 'as' infers from '-as'
+    '+columns'  => { len => { length => 'me.title' } },
   } => 'SELECT
           me.cdid,
           me.title,
@@ -73,6 +70,7 @@ my @chain = (
         FROM cd me'
     => [qw/cdid title len cnt foo bar genreid name rank/],
 
+
 );
 
 my $rs = $schema->resultset('CD');
@@ -95,7 +93,7 @@ while (@chain) {
   is_deeply(
     $rs->_resolved_attrs->{as},
     $as,
-    'Correct dbic-side aliasing',
+    "Correct dbic-side aliasing for test $testno",
   );
 
   $testno++;