Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Model.count not including all group fields

#588

I am trying to get number of events of by a certain person in a time period.

My activerecord syntax is:

Event.count(:group => [ 'DATE(created_at), user_id' ])

This returns something like:

=> [["1", 3], ["3", 1], ["4", 2], ["5", 1]]

It should have an extra date field there. Running the logged query directly in mysql returns the proper result:

SELECT count(*) AS count_all, DATE(created_at), user_id AS date_created_at_user_id FROM `events` GROUP BY DATE(created_at), user_id

+-----------+------------------+-------------------------+

| count_all | DATE(created_at) | date_created_at_user_id |

+-----------+------------------+-------------------------+

| 1 | 2008-05-08 | 1 |

| 1 | 2008-06-08 | 1 |

| 1 | 2008-06-20 | 3 |

| 1 | 2008-06-24 | 1 |

| 6 | 2008-07-08 | 1 |

| 2 | 2008-07-08 | 4 |

| 1 | 2008-07-08 | 5 |

| 3 | 2008-07-09 | 1 |

| 1 | 2008-07-09 | 3 |

| 1 | 2008-07-09 | 5 |

+-----------+------------------+-------------------------+

Reported by Marcelo Barbudas · July 10th, 2008 @ 12:44 AM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. josh
    josh
    • State changed from new to invalid

    October 12th, 2008 @ 08:11 PM