rails/rails — Issue #3483: Query using an array of integers and ranges
Author: sobrinho
Created: 2011-10-31 17:57:13+00:00
State: open

Hello,

irb:

``` ruby
puts User.where(:id => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30]).to_sql
#=> SELECT "users".* FROM "users" WHERE "users"."id" IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30)
puts User.where(:id => 1..10).to_sql
#=> SELECT "users".* FROM "users" WHERE "users"."id" BETWEEN 1 AND 10
puts User.where(:id => [1..10, 20, 30]).to_sql
#=> TypeError: Cannot visit Range
```

I'm expecting this:

``` ruby
puts User.where(:id => [1..10, 20, 30]).to_sql
#=> SELECT "users".* FROM "users" WHERE "users"."id" BETWEEN 1 AND 10 OR "users"."id" IN(20, 30)
```

Seems reasonable?