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

Fix where_clause#except with specific where value #28497

Merged
merged 1 commit into from
Mar 21, 2017
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
4 changes: 2 additions & 2 deletions activerecord/lib/active_record/relation/where_clause.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ def except_predicates_and_binds(columns)
(binds_index...(binds_index + binds_contains)).each do |i|
except_binds[i] = true
end

binds_index += binds_contains
end

binds_index += binds_contains if binds_contains

except
end

Expand Down
8 changes: 8 additions & 0 deletions activerecord/test/cases/relations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1970,6 +1970,14 @@ def test_unscope_with_subquery
assert_equal p2.first.comments, comments
end

def test_unscope_specific_where_value
posts = Post.where(title: "Welcome to the weblog", body: "Such a lovely day")

assert_equal 1, posts.count
assert_equal 1, posts.unscope(where: :title).count
assert_equal 1, posts.unscope(where: :body).count
end

def test_unscope_removes_binds
left = Post.where(id: Arel::Nodes::BindParam.new)
column = Post.columns_hash["id"]
Expand Down