[Dbix-class] Occasional problems with multilevel has_many prefetches

Nigel Metheringham nigel.metheringham at dev.intechnology.co.uk
Thu Nov 23 12:49:42 GMT 2006


Hi,

I have within my code a query that looks like this:-

     # join on everything useful here....
     my $join = [
         qw/event_status
           event_type
           company
           /,
        { bookings => 'performances' }
     ];

     my $attrs = {
         %{$attr},
         join     => $join,
         prefetch => $join,
         order_by => [ 'me.end_date', 'bookings.start' ],
     };

     my $res = $self->search( $search, $attrs );

bookings and performances are both has_many relationships, all the
others are belongs_to rels.

This query does not always return all the bookings objects for the top
level (event) objects.

The SQL appears to both be correct and return all the rows I would
expect.

If I remove the { bookings => 'performances' } fragment and add bookings
to the straight prefetch list, this works fine (but obviously I do a set
of subsidiary queries later when I access the performances rel).

Has anyone seen anything like this before, and have diagnosis
suggestions? I am somewhat dreading trying to write a test case to
demonstrate this effectively especially as it seems rather data
dependent.

[This is using DBIx::Class 0.07003 - in general all modules are current
as of this week as its a newish install]

	Nigel.
--
[ Nigel Metheringham           Nigel.Metheringham at InTechnology.co.uk ]
[ - Comments in this message are my own and not ITO opinion/policy - ]






More information about the Dbix-class mailing list