Frederick Cheung
2008-Sep-14 20:12 UTC
Anyone know what test_with_limiting_with_custom_select is testing
finder_test.rb (in active_record) has this test: def test_with_limiting_with_custom_select posts = Post.find(:all, :include => :author, :select => '' posts.*, authors.id as "author_id"'', :limit => 3, :order => ''posts.id'') assert_equal 3, posts.size assert_equal [0, 1, 1], posts.map(&:author_id).sort end But what is it testing (given that :include overwrites the select option) ? If the select wasn''t ignored then the test would fail as the author_id from posts would be overwritten by the one from the select, ie the post with author_id 0 would get an author_id of NULL (which I found out precisely because I have altered old-skool include not to squash :select) Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Sep-15 13:01 UTC
Re: Anyone know what test_with_limiting_with_custom_select is testing
d''oh sent to wrong list. Nothing to see here, move along ... Fred On 14 Sep 2008, at 21:12, Frederick Cheung wrote:> finder_test.rb (in active_record) has this test: > > def test_with_limiting_with_custom_select > posts = Post.find(:all, :include => :author, :select => '' posts.*, > authors.id as "author_id"'', :limit => 3, :order => ''posts.id'') > assert_equal 3, posts.size > assert_equal [0, 1, 1], posts.map(&:author_id).sort > end > > But what is it testing (given that :include overwrites the select > option) ? If the select wasn''t ignored then the test would fail as > the author_id from posts would be overwritten by the one from the > select, ie the post with author_id 0 would get an author_id of NULL > (which I found out precisely because I have altered old-skool > include not to squash :select) > > Fred--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---