From: "iain" <iainhubb...@googlemail.com>


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.


I know, but I would like to prefetch only just a few columns from the joined tables, not all of them.

Even if I would add to that arrayref some columns from the joined table, DBIC will get all the columns from those tables.

So, it is not possible to select only some specific columns from the joined tables?

Thanks.

Octavian


_______________________________________________
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/dbix-class@lists.scsys.co.uk

Reply via email to