From: "Ronald J Kimball" <rkimball+dbixcl...@pangeamedia.com>
Thomas L. Shinnick wrote:

I'm having some of the same questions regarding +select and +as .  It
seems that using '+select' and '+as' does not stop other columns from
being returned.  I'm using DBIC 0.08115.

What do you expect +select and +as to do??

+select

    Indicates additional columns to be selected from storage. Works
    the same as "select" but adds columns to the selection.

+as

    Indicates additional column names for those added via "+select".
    See "as".

+select and +as are behaving exactly as documented. If you want to select /only/ the specified columns use select and as, not +select and +as.

Ronald


Hi Ronald,

I am not sure my message will reach the list, because it rejects my messages as spam, but here is a short test I made:

$ENV{DBIC_TRACE}++;
use BRK::Schema;

my $schema = BRK::Schema->connect("dbi:mysql:database=brk", "root");

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?

Thank you.

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