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

I have TT labels to print data form the secondary table [% 
rsobject.relationship.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 fill 
all the labels ??????

I do not understand.

Migue.




________________________________
 De: Len Jaffe <[email protected]>
Para: Miguel Barco <[email protected]>; DBIx::Class user and developer 
list <[email protected]> 
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 <[email protected]> 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 table.
>
>
>¿Can it be avoided, or I need to make another schema without relationships?

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.
 -- 
[email protected]   614-404-4214
Proprietor: http://www.theycomewithcheese.com/ - An Homage to Fromage
Grubmaster: Greenbar 2011, 2010, 2009, Grub Asst. 2008, Trained 2007.
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to