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

Miguel Barco miguelelelele at yahoo.es
Mon Jan 2 10:17:43 GMT 2012


Wow!! It comes from the TT template!!!!

I have TT labels to print data form the secondary table [% rsobject.relatio=
nship.column %]

- When I prefetch, it hits database just once and data goes to its place in=
 the template.

- If I remove prefetch, it makes a SELECT for all the rows, looking for the=
 relationship!!
- If I remove the prefetch and the TT label in the template, it ignores the=
 secondary.

So Template Toolkit is calling back the relationship, forcing queries to fi=
ll all the labels ??????

I do not understand.

Migue.




________________________________
 De: Len Jaffe <lenjaffe at jaffesystems.com>
Para: Miguel Barco <miguelelelele at yahoo.es>; DBIx::Class user and developer=
 list <dbix-class at lists.scsys.co.uk> =

Enviado: lunes 2 de enero de 2012 4:46
Asunto: Re: [Dbix-class] I get only one in a one to one
 =





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 noti=
ced that the relationship is always present, even when I want to retrieve j=
ust columns from the main table.
>
>
>After a query without prefetch, it hits the database with a "SELECT from t=
he secondary table" for each one of the rows found from the primary table.
>
>
>=BFCan it be avoided, or I need to make another schema without relationshi=
ps?

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:

=A0sub main_RS {
=A0 =A0 =A0return $self->search(the_main_query_to_search_the_main_rows)
}

sub main_with_related {
=A0 =A0return $self->main_RS_method()->search_related(the_has_one_accessor) =

}

Len.
=A0-- =

lenjaffe at jaffesystems.com=A0=A0 614-404-4214
Proprietor: http://www.theycomewithcheese.com/ - An Homage to Fromage
Grubmaster: Greenbar 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/20120102/ebd=
ae26b/attachment-0001.htm


More information about the DBIx-Class mailing list