Teach FC about literals
[dbsrgits/DBIx-Class.git] / t / prefetch / manual.t
index 1ad2253..e051ce3 100644 (file)
@@ -63,7 +63,7 @@ my $rs = $schema->resultset ('CD')->search ({}, {
     { 'title'                                   => 'me.title' },              # uniquiness for me
     { 'artist'                                  => 'me.artist' },             # uniquiness for me
   ],
-  order_by => [{ -desc => 'cds.year' }, { -desc => 'me.title'} ],
+  order_by => [{ -desc => 'cds.year' }, { -desc => 'me.title'}, 'tracks.title', 'tracks_2.title' ],
 });
 
 my $hri_rs = $rs->search({}, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' });
@@ -220,29 +220,6 @@ lives_ok { my $dummy = $rs;  warnings_exist {
 ], 'expected_warnings'
 } 'traversing prefetch chain with empty intermediates works';
 
-TODO: {
-local $TODO = 'this does not work at all, need to promote rsattrs to an object on its own';
-# make sure has_many column redirection does not do weird stuff when collapse is requested
-for my $pref_args (
-  { prefetch => 'cds'},
-  { collapse => 1 }
-) {
-  for my $col_and_join_args (
-    { '+columns' => { 'cd_title' => 'cds_2.title' }, join => [ 'cds', 'cds' ] },
-    { '+columns' => { 'cd_title' => 'cds.title' }, join => 'cds', }
-  ) {
-
-    my $weird_rs = $schema->resultset('Artist')->search({}, {
-      %$col_and_join_args, %$pref_args,
-    });
-
-    for (qw/next all first/) {
-      throws_ok { $weird_rs->$_ } qr/not yet determined exception text/;
-    }
-  }
-}
-}
-
 # multi-has_many with underdefined root, with rather random order
 $rs = $schema->resultset ('CD')->search ({}, {
   join => [ 'tracks', { single_track => { cd => { artist => { cds => 'tracks' } } } }  ],
@@ -280,24 +257,20 @@ if ($ENV{TEST_VERBOSE}) {
     for @lines;
 }
 
-{
-  my $queries = 0;
-  $schema->storage->debugcb(sub { $queries++ });
-  my $orig_debug = $schema->storage->debug;
-  $schema->storage->debug (1);
-
+$schema->is_executed_querycount( sub {
   for my $use_next (0, 1) {
     my @random_cds;
+    my $rs_r = $rs_random;
     if ($use_next) {
       warnings_exist {
-        while (my $o = $rs_random->next) {
+        while (my $o = $rs_r->next) {
           push @random_cds, $o;
         }
       } qr/performed an eager cursor slurp underneath/,
       'Warned on auto-eager cursor';
     }
     else {
-      @random_cds = $rs_random->all;
+      @random_cds = $rs_r->all;
     }
 
     is (@random_cds, 6, 'object count matches');
@@ -329,11 +302,7 @@ if ($ENV{TEST_VERBOSE}) {
       }
     }
   }
-
-  $schema->storage->debugcb(undef);
-  $schema->storage->debug($orig_debug);
-  is ($queries, 2, "Only two queries for two prefetch calls total");
-}
+}, 2, "Only two queries for two prefetch calls total");
 
 # can't cmp_deeply a random set - need *some* order
 my $ord_rs = $rs->search({}, {