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@@@SELECT count(posts.*) FROM posts@@@ 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])
it picks up the id from the forums table, not the posts table.
Is there a way you could add a ":select_for_count" parameter?
I suppose you could get around this by adding your own total_entries parameter, but that seems less dry than capturing it in the finder
Comments and changes to this ticket
-
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
People watching this ticket
- Nobody is watching this ticket.
Referenced by
- 57 Will paginate breaks with :select and sum() The following query results in a sql error. The problem ...