Karol Hosiawa
2005-Apr-26 11:22 UTC
find (:all, :include=>:something, :limit=>4) doesn''t work
find (:all, :include=>:something, :limit=>4) doesn''t work Seems like putting :include together with :limit doesn''t execute LIMIT statement -- Karol Hosiawa
Jarkko Laine
2005-Apr-26 11:43 UTC
Re: find (:all, :include=>:something, :limit=>4) doesn''t work
Karol, On 26.4.2005, at 14:22, Karol Hosiawa wrote:> find (:all, :include=>:something, :limit=>4) doesn''t work > Seems like putting :include together with :limit doesn''t execute LIMIT > statementThis is a known shortcoming. The limit parameter is passed to the actual query and there''s no idea limiting a left join query. It would limit the number of total joined rows returned, not the number of "primary" objects. The only way to get this working would be to use subqueries in case of :include and push the :limit parameter inside the subquery. //jarkko> -- > Karol Hosiawa > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Stefan Kaes
2005-Apr-26 11:44 UTC
Re: find (:all, :include=>:something, :limit=>4) doesn''t work
Karol Hosiawa wrote:> find (:all, :include=>:something, :limit=>4) doesn''t work > Seems like putting :include together with :limit doesn''t execute LIMIT > statement > -- > Karol Hosiawa > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >Quote from the doc: Please note that because eager loading is fetching both models and associations in the same grab, it doesn’t make sense to use the :limit property and it will be ignored if attempted. -- stefan