rails/rails — pull request #17330 by DanOlson (2014-10-20 00:48:03+00:00)
Title: Fix Relation.rewhere to work with Range values

I noticed `Relation.rewhere` wasn't working with ranges:

```ruby
Post.where(comments_count: 1..3).rewhere(comments_count: 3..5).to_sql
=> "SELECT \"posts\".* FROM \"posts\" WHERE (\"posts\".\"comments_count\" BETWEEN 1 AND 3) AND (\"posts\".\"comments_count\" BETWEEN 3 AND 5)"
```

This patch ensures the above relation produces the correct SQL:

```ruby
Post.where(comments_count: 1..3).rewhere(comments_count: 3..5).to_sql
=> "SELECT \"posts\".* FROM \"posts\" WHERE (\"posts\".\"comments_count\" BETWEEN 3 AND 5)"
```