[Dbix-class] Fwd: [Catalyst] Selecting from more tables (DBIC- bug?)

iain iainhubbard at googlemail.com
Tue Jan 19 17:29:33 GMT 2010


> my $uuu = $schema->resultset('User')->search({},{
> prefetch => {blogs => 'blog_comments'},
> select => ['me.id'],
> as => ['user_id'],
> });
>
> print $uuu->first->username;
>
> I think the single column that should be printed should be me.id, but 
> here is the generated SQL:
>
> SELECT me.id, blogs.id, blogs.user, blogs.date_create, 
> blogs.date_modify, blogs.title, blogs.body, blogs.markup_lang, 
> blogs.tags, blogs.active, blog_comments.id, blog_comments.user, 
> blog_comments.blog, blog_comments.date_time, blog_comments.body, 
> blog_comments.markup_lang, blog_comments.active FROM user me LEFT JOIN 
> blog blogs ON blogs.user = me.id LEFT JOIN blog_comment blog_comments 
> ON blog_comments.blog = blogs.id ORDER BY blogs.user, blog_comments.blog:
>
> Is it normal to get all the columns from the joined tables?
>

Yes. You have asked DBIC to prefetch the data from the blogs tables. So 
it has.

Iain.





More information about the DBIx-Class mailing list