Will paginate breaks with :select and sum()
Reported by Christian | July 13th, 2007 @ 12:15 AM
The following query results in a sql error. The problem seems to be a similar one like in #45, but the problem is actually the sum(), not the count().
entries = Entry.paginate(:all, :select => "entry.*, SUM(v.counter) as popularity",
:joins => 'as entry inner join views as v on entry.id = v.entry_id',
:group => 'entry.id',
:order => 'popularity DESC',
:limit => 50,
:per_page => 8, :page => params[:page])
Mysql::Error:
SELECT count(*entry., SUM(v.counter) as popularity) AS count_entry_all_sum_v_counter_as_popularity, entry.id AS entry_id FROM entries as entry inner join views as v on entry.id = v.entry_id GROUP BY entry.id LIMIT 50
Comments and changes to this ticket
-
Chris Wanstrath July 13th, 2007 @ 12:15 AM
- State changed from new to open
- Assigned user changed from Chris Wanstrath to Mislav
-
Chris Wanstrath July 13th, 2007 @ 12:15 AM
- State changed from open to resolved
(from [294]) will_paginate: dont need :select in count() [#57 state:resolved]
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป