Skip to content

Commit

Permalink
Ensure AssociationCollection#count works with empty condition. [#271
Browse files Browse the repository at this point in the history
…state:resolved] [Jan De Poorter]
  • Loading branch information
lifo committed May 29, 2008
1 parent 4d24854 commit abb1bd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Expand Up @@ -9,7 +9,7 @@ def count(*args)
@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]
Expand Down
Expand Up @@ -32,6 +32,10 @@ def test_counting
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
Expand Down

0 comments on commit abb1bd2

Please sign in to comment.