[Dbix-class] +as not applied in +select/join/group_by
Christian Lackas
lackas at lackas.net
Fri May 29 07:35:46 GMT 2009
Hi Everbody,
I have trouble formulating this raw SQL in DBIx::Class:
SELECT publiclinks.*, COUNT(publicdownloads.id) AS downloadcount
FROM publiclinks, publicdownloads
WHERE publicdownloads.linkid = publiclinks.id
GROUP BY publiclinks.id;
with publiclinks storing a list of resources, which can be downloaded.
This is logged into publicdownloads and my goal is to get a joined table, which
additionally shows me how often each resources was requested.
To accomplish this, I already tried the following (has_many relationship
between tables is named 'downloads'):
$rs>search({}, {
join => 'downloads',
'+select' => [ { count => 'downloads.id' } ],
'+as' => [ 'downloadcount' ],
group_by => 'me.id',
});
Unfortunately, this only produces this (DBIC_TRACE):
SELECT me.*, COUNT( downloads.id ) FROM publiclinks me
LEFT JOIN publicdownloads downloads ON downloads.linkid = me.id
GROUP BY me.id
Why is the '+as' not applied here? And is this the right approach?
Using DBIx::Class 0.08102.
Thanks for your help.
Christian
--
inviCRO, LLC -- In Imaging Yours
http://www.invicro.com/ http://www.spect-ct.com/
More information about the DBIx-Class
mailing list