rails/rails — pull request #17478 by agrobbin (2014-11-01 19:35:09+00:00)
Title: allow array or hash syntax for partial index conditions

This is the newer version of #13353, based off of the latest master. It allows you to replace these migrations:

```ruby
add_index :foos, :user_id, unique: true, where: "status IN (0, 1)"
```

With this:

```ruby
add_index :foos, :user_id, unique: true, where: { status: [1, 2] }
```

It understands any Array that `ActiveRecord::Sanitization.sanitize_sql_array` accepts, and any Hash that `ActiveRecord::PredicateBuilder` accepts. It would've been great to just use `ActiveRecord::Sanitization.sanitize_sql_for_conditions` directly, but its implementation of `sanitize_sql_hash_for_conditions` assumes it is being called from within a `ActiveRecord::Base` class, which this is not. Figured this was a reasonable first pass!