[Dbix-class] Why would order_by interfere with has many fetch?

Matija Grabnar matija at serverflow.com
Fri Aug 8 07:29:40 GMT 2014


I have a hierarchical bunch of tables.
A has many B has many C.

I wanted to do a search of the form

   my $h = $hosts->search
     ({},
      {
       order_by => ['me.field_in_a'],
       join => {'bs' => 'cs'},
       prefetch => {'bs' => 'cs'},
      },
     );

But I get a warning:

DBIx::Class::ResultSet::_construct_results(): Unable to properly 
collapse has_many results in iterator mode due to order criteria - 
performed an eager cursor slurp underneath. Consider using ->all() instead

(The warning goes away if I comment out the prefetch).

Why? Surely, as long as the order of keys is the same as the hierarchy, 
(i.e. A.field, B.field, C.field or even A.field1, A.field2, C.field) the 
select with the sort should work just as well as the one without?

Am I missing something?







More information about the DBIx-Class mailing list