This project is archived and is in readonly mode.

#5441 ✓resolved
oleg dashevskii

[PATCH] ActiveRecord::Calculations#count doesn't allow table names in column_name argument

Reported by oleg dashevskii | August 24th, 2010 @ 02:19 PM | in 3.0.2

I have the following code that works in 2.3.8

              :group => '',
              :joins => {:multi_dishes => { :menu_item => :order_items }})

@dishes is some Dish scope. This code counts how many times each dish appeared in orders.

When I try to run it under 3.0.0.rc2, it fails (@dishes = Dish):

ActiveRecord::StatementInvalid: Mysql::Error: Unknown column '' in 'field list': SELECT COUNT(
AS count_order_items_id, AS dishes_id FROM dishes
INNER JOIN multi_dishes ON multi_dishes.dish_id = INNER JOIN menu_items ON = multi_dishes.menu_item_id
INNER JOIN order_items ON order_items.menu_item_id = GROUP BY

The problem is apparent: unneeded 'dishes.' prepended to the column name.

I also tried to specify :select option, but it made no change.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

Referenced by