Subject: | Duplicated columns with 'having' |
Hello,
I have also mentioned this issue on IRC and on the mailing list, but
I've been told to also report it here.
I have run into a bug when using an aggregate function and setting two
or more possible values to the same column in the 'having' clause.
Example:
my $rs = $schema->resultset("Artist")->search(
{},
{
join => 'cds',
group_by => 'me.artistid',
'+select' => [ { max => 'cds.year', -as => 'newest_cd_year' } ],
'+as' => ['newest_cd_year'],
having => { 'newest_cd_year' => [ '1998', '2001' ] }
}
);
As the 'newest_cd_year' has two possible values (1998 and 2001), count()
will add "MAX(cds.year) AS newest_cd_year" twice to the 'select'
attribute. This happens only with count(). $rs->all, for example, would
generate the query correctly.
I have submitted a patch in the branch
'topic/duplicate_columns_having_count'.
Would somebody review the code and merge it to master, please?