[Dbix-class] I get only one in a one to one

Len Jaffe lenjaffe at jaffesystems.com
Mon Jan 2 03:46:37 GMT 2012


On Sun, Jan 1, 2012 at 6:03 PM, Miguel Barco <miguelelelele at yahoo.es> wrote:

> Thank you!, now I can get all data. But the problem now is that I have
> noticed that the relationship is always present, even when I want to
> retrieve just columns from the main table.
>
> After a query without prefetch, it hits the database with a "SELECT from
> the secondary table" for each one of the rows found from the primary tabl=
e.
>
> =BFCan it be avoided, or I need to make another schema without relationsh=
ips?
>

One method to return the result_set with out the prefetch, and one to chain
the prefetch onto the first.
This is not tested code:

 sub main_RS {
     return $self->search(*the_main_query_to_search_the_main_rows*)
}

sub main_with_related {
   return $self->main_RS_method()->search_related(*the_has_one_accessor*)
}

Len.

-- =

lenjaffe at jaffesystems.com   614-404-4214
Proprietor: http://www.theycomewithcheese.com/ - An Homage to Fromage
Grubmaster: Greenbar <http://www.greenbartraining.org/> 2011, 2010, 2009,
Grub Asst. 2008, Trained 2007.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120101/d50=
26457/attachment.htm


More information about the DBIx-Class mailing list