Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

unscope should remove bind values associated with the where

  • Loading branch information...
commit f1764a2de17bba07bad3ec0d88de152d8279d3bb 1 parent 1e2d7c2
@tenderlove tenderlove authored
View
2  activerecord/lib/active_record/relation/query_methods.rb
@@ -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)
View
9 activerecord/test/cases/relations_test.rb
@@ -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']
Please sign in to comment.
Something went wrong with that request. Please try again.