Permalink
Browse files

Merge pull request #10317 from arabonradar/ar_having_values_bug_fix

ActiveRecord having clause bug fix
  • Loading branch information...
2 parents 1bd92ed + 746a999 commit 5af29cbde8c10f081bd8216338d0cdb661e23fb3 @rafaelfranca rafaelfranca committed Apr 23, 2013
@@ -551,7 +551,6 @@ def where!(opts = :chain, *rest) # :nodoc:
# Order.having('SUM(price) > 30').group('user_id')
def having(opts, *rest)
opts.blank? ? self : spawn.having!(opts, *rest)
- spawn.having!(opts, *rest)
end
def having!(opts, *rest) # :nodoc:
@@ -1299,6 +1299,14 @@ def test_distinct
assert_equal ['Foo', 'Foo'], query.uniq(true).uniq(false).map(&:name)
end
+ def test_doesnt_add_having_values_if_options_are_blank
+ scope = Post.having('')
+ assert_equal [], scope.having_values
+
+ scope = Post.having([])
+ assert_equal [], scope.having_values
+ end
+
def test_references_triggers_eager_loading
scope = Post.includes(:comments)
assert !scope.eager_loading?

0 comments on commit 5af29cb

Please sign in to comment.