Fixing behaviour of where unscoping to not leak

As per issue #17738 this will prevent calls to .unscope from
altering the original query's where_values collection.

The new test in where_chain_test.rb passes.

The test 'HasManyThroughAssociationsTest#test_has_many_through_unscope_default_scope'
now fails and needs more investigation.

Submitting this as a PR despite the broken test so that other contributors can investigate the new test and help figure out the underlying cause (I had a brief look but couldn't see why it started breaking after the change).
This test is very tightly coupled to the internal implementation. Can we do something like this instead?

```ruby
first_post = posts(:welcome)
second_post = posts(:thinking)
relation = Post.where(title: first_post.title)
rewhered = Post.rewhere(title: second_post.title)

assert_equal [first_post], relation.to_a
assert_equal [second_post], rewhered.to_a
```