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.

Will paginate breaks with :select and sum()

#57

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

Reported by Christian · July 13th, 2007 @ 12:15 AM

State: resolved
Milestone: none
Assigned to: Mislav Mislav

Activity

  1. Chris Wanstrath
    Chris Wanstrath
    • State changed from new to open
    • Assigned user changed from Chris Wanstrath to Mislav

    July 13th, 2007 @ 12:15 AM

  2. Chris Wanstrath
    Chris Wanstrath
    • State changed from open to resolved

    (from [294]) will_paginate: dont need :select in count() [#57 state:resolved]

    http://require.errtheblog.com/pl...

    July 13th, 2007 @ 12:15 AM

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.