[Dbix-class] Code Review - Duplicated columns with 'having'

André Walker andre at andrewalker.net
Wed Feb 13 16:42:24 GMT 2013


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.


   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

I have submitted a patch in the branch 'topic/duplicate_columns_having_count'.
Would somebody review the code and merge it to master, please?

Thank you,

More information about the DBIx-Class mailing list