Revert "Merge pull request #10539 from davidcelis/ar-sql-improvements"

This reverts commit 257fa6897d9c85da16b7c9fcb4ae3008198d320e, reversing
changes made to 94725b81f5588e4b0f43222c4f142c3135941b4b.

The build failed

https://travis-ci.org/rails/rails/builds/7883546