Iain Hubbard <[EMAIL PROTECTED]> writes:

> On Wed, 2008-07-30 at 14:55 +0200, BUNK (Jacob Bunk Nielsen) wrote:
>> $baskets->search({ },
>>           { select => [ { count => 'item_id' }, ],
>>             as => [ 'no_of_items' ],
>>             group_by => [ 'basket_id' ],
>>            })->get_column('no_of_items')->max;
>>
>> Unfortunately this doesn't cut it. It ends up complaining that there is
>> no column called 'no_of_items' for the query:
>>
>> SELECT MAX( "no_of_items" )
>>  FROM "shop"."basket" "me"
>>  WHERE ( ( ( "basket_id" = ? ) OR ( "basket_id" = ? ) ) )
>>  GROUP BY "basket_id"" with ParamValues: 1='1', 2='2'
>>
>> It totally ignores my part about 'select count(item_id) as no_of_items'.
>>
>> How do I make dbix-class make the right database query?
>
> I think its the as => [ 'no_of_items' ] not doing what you think.

Perhaps, but it also ignores any mentioning of 'count'. This doesn't
seem logical to me. Do you have any idea why it ignores count?

Best regards

Jacob

_______________________________________________
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/[EMAIL PROTECTED]

Reply via email to