#57 ✓resolved

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])


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

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.

New-ticket Create new ticket

Create your profile

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

Shared Ticket Bins

People watching this ticket