#45 ✓invalid
Jeff Dean

Will paginate breaks with :select and :join in mysql

Reported by Jeff Dean | June 23rd, 2007 @ 09:28 PM

This is actually as much a MySQL bug as it is a will_paginate bug, but since it's easier to change will_paginate...

The following statement

Post.paginate(:select=>'posts.*', 
  :joins=>"inner join forums on posts.forum_id = forums.id", 
  :page=>params[:page])

Produces the following sql

which is invalid in mysql

However, if you just put

Post.paginate(:joins=>"inner join forums on posts.forum_id = forums.id",

:page=>params[:page])

Comments and changes to this ticket

  • Jeff Dean

    Jeff Dean June 23rd, 2007 @ 09:28 PM

    My bad - I didn't read the documentation well enough.

    The count parameter does exactly what I need - so in the case above (for anyone finding this) the solution is:

    Post.paginate(:select=>'posts.*', 
      :joins=>"inner join forums on posts.forum_id = forums.id", 
      :page=>params[:page],
     :count=>{:select=>'*'})
    

    This was an invalid bug - sorry about that.

  • Chris Wanstrath

    Chris Wanstrath June 23rd, 2007 @ 09:28 PM

    • State changed from “new” to “invalid”

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

Referenced by

Pages