Permalink
Browse files

Ensure AssociationCollection#count works with empty condition. [#271

…state:resolved] [Jan De Poorter]
  • Loading branch information...
1 parent 4d24854 commit abb1bd2efa43b8efbb3faf4ccfb9246704a9044c @lifo lifo committed May 29, 2008
@@ -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]
@@ -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

0 comments on commit abb1bd2

Please sign in to comment.