[Dbix-class] A count() after a grouping select() produces a "Duplicate column" error

Gerhard Jungwirth gjungwirth at sipwise.com
Tue Oct 10 14:26:21 GMT 2017


just guessing, did you try

group_by => [ 'me.quantity' ]


On 2017-10-10 13:20, Vladimir Melnik wrote:
> Dear colleagues,
>
> Here's a little snippet of the code:
> 	$resultset
> 	    ->search(undef, { group_by => [ qw(quantity) ] })
> 	    ->count;
>
> It produces the following exception:
> DBI Exception: DBD::mysql::st execute failed: Duplicate column name 'quantity' [for Statement "SELECT COUNT( * ) FROM (SELECT me.id, me.valid_from, me.valid_till, me.removed, me.provisioning_agreement_id, me.resource_piece_id, me.service_type_id, me.service_level_id, me.quantity, me.quantity FROM provisioning_obligation me GROUP BY quantity) me"] at /home/mmkeeper/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/DBIx/Class/Schema.pm line 1118.
>
> What is the best way to avoid that?
>
> Thanks in advance!
>




More information about the DBIx-Class mailing list