Ticket #8801: 1-2-stable.diff
| File 1-2-stable.diff, 2.1 kB (added by court3nay, 1 year ago) |
|---|
-
activerecord/test/associations/join_model_test.rb
old new 29 29 assert_equal 2, authors(:mary).categorized_posts.size 30 30 assert_equal 1, authors(:mary).unique_categorized_posts.size 31 31 end 32 32 33 def test_has_many_uniq_through_count 34 author = authors(:mary) 35 assert !authors(:mary).unique_categorized_posts.loaded? 36 assert_queries(1) { assert_equal 1, author.unique_categorized_posts.count } 37 assert_queries(1) { assert_equal 1, author.unique_categorized_posts.count(:title, {}) } 38 assert_queries(1) { assert_equal 0, author.unique_categorized_posts.count(:title, { :conditions => "title is NULL" }) } 39 assert !authors(:mary).unique_categorized_posts.loaded? 40 end 41 33 42 def test_polymorphic_has_many 34 43 assert posts(:welcome).taggings.include?(taggings(:welcome_general)) 35 44 end -
activerecord/lib/active_record/associations/has_many_through_association.rb
old new 101 101 def sum(*args, &block) 102 102 calculate(:sum, *args, &block) 103 103 end 104 105 def count(*args) 106 column_name, options = @reflection.klass.send(:construct_count_options_from_legacy_args, *args) 107 if @reflection.options[:uniq] 108 # This is needed becase 'SELECT count(DISTINCT *)..' is not valid sql statement. 109 column_name = "#{@reflection.klass.table_name}.#{@reflection.klass.primary_key}" if column_name == :all 110 options.merge!(:distinct => true) 111 end 112 @reflection.klass.send(:with_scope, construct_scope) { @reflection.klass.count(column_name, options) } 113 end 104 114 105 115 protected 106 116 def method_missing(method, *args, &block)