rails/rails — pull request #4082 by al2o3cr (2011-12-20 21:25:15+00:00)
Title: Fix reorder with limited ids

(trying again with the correct base branch)

Calling `last` on an association that's scoped with `reorder` can cause some adapters to fail (particularly oracle_enhanced and postgres). The underlying cause is that `connection.distinct` expects the desired order, but the relation's `reorder_values` are not passed along, since `construct_limited_ids` explicitly grabs `order_values`.

See the attached commit for additional details - this bug does not affect the mysql or sqlite adapters, as those use the default order-agnostic implementation of `distinct`.

What's the best way to test this?