Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActiveRecord having clause bug fix #10317

Merged
merged 1 commit into from Apr 23, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion activerecord/lib/active_record/relation/query_methods.rb
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions activerecord/test/cases/relations_test.rb
Expand Up @@ -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?
Expand Down