rails/rails — pull request #17185 by brocktimus (2014-10-05 23:18:48+00:00)
Title: Failing test for #12753

I did a lot of hunting around and managed to produce a failing test and isolate where issue is coming from. This also possibly relates somewhat to #15920.

I've added a note near where the "bug starts". Basically if there are two bind params both referencing a single column when we do parameter replacement they're both replace with a common index. This fails with prepared statements and executing because some of the parameters are no longer used and the adapter raises unknown data type (or similar).

I realise my test could be fixed by changing my scope to have ```unscoped.select(:parent_id)``` but it was the first failing test I could come up with after a lot of trying to integrate it into the codebase. Will be trying to "adjust" it to a more correct / succinct test case.

I don't know where / how to start fixing this however, so I'll CC people I've seen working on this or similar code. Any ideas? @tenderlove @sgrif @eileencodes @senny