mirror of
https://github.com/github/rails.git
synced 2026-01-28 15:58:03 -05:00
Ensure AssociationCollection#count works with empty condition. [#271 state:resolved] [Jan De Poorter]
This commit is contained in:
@@ -9,7 +9,7 @@ module ActiveRecord
|
||||
@reflection.klass.count_by_sql(@finder_sql)
|
||||
else
|
||||
column_name, options = @reflection.klass.send(:construct_count_options_from_args, *args)
|
||||
options[:conditions] = options[:conditions].nil? ?
|
||||
options[:conditions] = options[:conditions].blank? ?
|
||||
@finder_sql :
|
||||
@finder_sql + " AND (#{sanitize_sql(options[:conditions])})"
|
||||
options[:include] ||= @reflection.options[:include]
|
||||
|
||||
@@ -32,6 +32,10 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
|
||||
assert_equal 2, Firm.find(:first).plain_clients.count
|
||||
end
|
||||
|
||||
def test_counting_with_empty_hash_conditions
|
||||
assert_equal 2, Firm.find(:first).plain_clients.count(:conditions => {})
|
||||
end
|
||||
|
||||
def test_counting_with_single_conditions
|
||||
assert_equal 2, Firm.find(:first).plain_clients.count(:conditions => '1=1')
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user