提交 aed797eb 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #28976 from kamipo/should_test_bound_attributes

Should test against `Relation#bound_attributes`
......@@ -1981,24 +1981,28 @@ def test_unscope_specific_where_value
end
def test_unscope_removes_binds
left = Post.where(id: Arel::Nodes::BindParam.new)
column = Post.columns_hash["id"]
left.bind_values += [[column, 20]]
left = Post.where(id: 20)
binds = [bind_attribute("id", 20, Post.type_for_attribute("id"))]
assert_equal binds, left.bound_attributes
relation = left.unscope(where: :id)
assert_equal [], relation.bind_values
assert_equal [], relation.bound_attributes
end
def test_merging_removes_rhs_bind_parameters
def test_merging_removes_rhs_binds
left = Post.where(id: 20)
right = Post.where(id: [1, 2, 3, 4])
binds = [bind_attribute("id", 20, Post.type_for_attribute("id"))]
assert_equal binds, left.bound_attributes
merged = left.merge(right)
assert_equal [], merged.bind_values
assert_equal [], merged.bound_attributes
end
def test_merging_keeps_lhs_bind_parameters
binds = [ActiveRecord::Relation::QueryAttribute.new("id", 20, Post.type_for_attribute("id"))]
def test_merging_keeps_lhs_binds
binds = [bind_attribute("id", 20, Post.type_for_attribute("id"))]
right = Post.where(id: 20)
left = Post.where(id: 10)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册