Jeremy Hopple
2005-Dec-12 21:10 UTC
Re: #2760 - Add support for :include to ActiveRecord::Base.count
I came across this ticket: http://dev.rubyonrails.org/ticket/2760. The patch I submitted for http://dev.rubyonrails.org/ticket/2597 also, and probably more specifically, relates to this ticket. In other words, the fix for #2597 depends upon the enhancement called for in #2760. These tickets could probably be cleaned up and consolidated. Thanks, Jeremy On 12/10/05, Jeremy Hopple <jeremy@jthopple.com> wrote:> http://dev.rubyonrails.org/ticket/2597 > > I have uploaded a patch that enhances/refactors Model.count (and couple of > other things) so that paginate works, as advertised, with named associations > (and eager loading). This patch works great for me. It passes all the AR > unit tests in MySQL, but a couple fail in sqlite. Please read the comments > I posted in the ticket about the patch I uploaded and let me know what you > all think. > > Thanks, > Jeremy >
Jeremy Hopple
2005-Dec-13 00:14 UTC
Re: #2760 - Add support for :include to ActiveRecord::Base.count
http://dev.rubyonrails.org/ticket/2597 All AR unit tests now pass in MySQL, Postgress and sqlite3. Check it out! You can now do: Posts.count(:include => :authors, :conditions => "authors.name = ''david''") and (limiting with eager loading): Posts.find(:all, :include => :authors, :conditions => "authors.name ''david''", :limit => 10, :offset => 11) As a bonus, these changes enable people to use paginate with :include, like: @post_pages, @posts paginate(:posts, :per_page => 10, :include => :authors, :conditions => "authors.name = ''david''") In addition to making a patch, I''ve also created a plugin that does the same thing so that it''s available if anyone needs it. Thanks, Jeremy On 12/12/05, Jeremy Hopple <jeremy@jthopple.com> wrote:> I came across this ticket: http://dev.rubyonrails.org/ticket/2760. > The patch I submitted for http://dev.rubyonrails.org/ticket/2597 also, > and probably more specifically, relates to this ticket. In other > words, the fix for #2597 depends upon the enhancement called for in > #2760. > > These tickets could probably be cleaned up and consolidated. > > Thanks, > Jeremy > > On 12/10/05, Jeremy Hopple <jeremy@jthopple.com> wrote: > > http://dev.rubyonrails.org/ticket/2597 > > > > I have uploaded a patch that enhances/refactors Model.count (and couple of > > other things) so that paginate works, as advertised, with named associations > > (and eager loading). This patch works great for me. It passes all the AR > > unit tests in MySQL, but a couple fail in sqlite. Please read the comments > > I posted in the ticket about the patch I uploaded and let me know what you > > all think. > > > > Thanks, > > Jeremy > > >