Permalink
Browse files

unscope should remove bind values associated with the where

  • Loading branch information...
tenderlove committed Jan 14, 2014
1 parent 1e2d7c2 commit f1764a2de17bba07bad3ec0d88de152d8279d3bb
@@ -880,6 +880,8 @@ def where_unscoping(target_value)
raise "unscope(where: #{target_value.inspect}) failed: unscoping #{rel.class} is unimplemented."
end
end
+
+ bind_values.reject! { |col,_| col.name == target_value }
end
def custom_join_ast(table, joins)
@@ -1524,6 +1524,15 @@ def test_presence
assert merged.to_sql.include?("bbq")
end
+ def test_unscope_removes_binds
+ left = Post.where(id: Arel::Nodes::BindParam.new('?'))
+ column = Post.columns_hash['id']
+ left.bind_values += [[column, 20]]
+
+ relation = left.unscope(where: :id)
+ assert_equal [], relation.bind_values
+ end
+
def test_merging_removes_rhs_bind_parameters
left = Post.where(id: Arel::Nodes::BindParam.new('?'))
column = Post.columns_hash['id']

0 comments on commit f1764a2

Please sign in to comment.