1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

When empty options passed to having clause having_values was [nil] but should be empty.

This commit is contained in:
Fyodor 2013-04-23 17:07:49 +04:00
parent a56b150b64
commit 746a9992f0
2 changed files with 8 additions and 1 deletions

View file

@ -551,7 +551,6 @@ module ActiveRecord
# 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:

View file

@ -1299,6 +1299,14 @@ class RelationTest < ActiveRecord::TestCase
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?