Fix query with nested array in Active Record

`User.where(id: [[1, 2], 3])` was equal to `User.where(id: [1, 2, 3])` in
Rails 4.1.x but because of some refactoring in Arel this stopped working.
We had to fix this in Rails. Also added the ability to query array fields
(supported by PostgreSQL so far). Example: User.where(tags: [['tag1', 'tag2']])

Fixes #16580. Continuation of #16805