File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed
lib/active_record/relation Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 1+ * Do not allow passing the column name to ` count ` when a block is passed.
2+
3+ * Rafael Mendonça França*
4+
15* Remove delegation of missing methods in a relation to arel.
26
37 * Rafael Mendonça França*
Original file line number Diff line number Diff line change @@ -41,15 +41,13 @@ module Calculations
4141 def count ( column_name = nil )
4242 if block_given?
4343 unless column_name . nil?
44- ActiveSupport ::Deprecation . warn \
45- "When `count' is called with a block, it ignores other arguments. " \
46- "This behavior is now deprecated and will result in an ArgumentError in Rails 6.0."
44+ raise ArgumentError , "Column name argument is not supported when a block is passed."
4745 end
4846
49- return super ( )
47+ super ( )
48+ else
49+ calculate ( :count , column_name )
5050 end
51-
52- calculate ( :count , column_name )
5351 end
5452
5553 # Calculates the average value on a given column. Returns +nil+ if there's
Original file line number Diff line number Diff line change @@ -917,9 +917,9 @@ def test_group_by_attribute_with_custom_type
917917 assert_equal ( { "proposed" => 2 , "published" => 2 } , Book . group ( :status ) . count )
918918 end
919919
920- def test_deprecate_count_with_block_and_column_name
921- assert_deprecated do
922- assert_equal 6 , Account . count ( :firm_id ) { true }
920+ def test_count_with_block_and_column_name_raises_an_error
921+ assert_raises ( ArgumentError ) do
922+ Account . count ( :firm_id ) { true }
923923 end
924924 end
925925
You can’t perform that action at this time.
0 commit comments