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

Peter Rabbitson rabbit+dbic at rabbit.us
Tue Aug 12 14:10:05 GMT 2014


On 08/08/2014 09:29 AM, Matija Grabnar wrote:
> 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?
>

Please try the latest trial release (suitable to run in production), as 
the problem above seems like an addressed bug: 
https://metacpan.org/changes/release/RIBASUSHI/DBIx-Class-0.082700_05#L30

The 0.082700_05 is supposed to become stable in 20h or so, baring any 
reports of issues by users like you.

You can get the dev version using any of the following methods:

HARNESS_OPTIONS=j4 cpan R/RI/RIBASUSHI/DBIx-Class-0.082700_05.tar.gz
   or
HARNESS_OPTIONS=j4 cpanm -v DBIx::Class at 0.082700_05
   or by grabbing the tarball
http://cpan.metacpan.org/authors/id/R/RI/RIBASUSHI/DBIx-Class-0.082700_05.tar.gz

Cheers



More information about the DBIx-Class mailing list