rails/rails — pull request #5029 by thatRD (2012-02-13 19:12:32+00:00)
Title: Ask Connection to quote symbolic column names when building ORDER BY

In some databases (e.g, mysql) column names referenced in ORDER BY clauses
should be quoted in case they are reserved words. This corrects an issue that
occurs when using the ```Model.order(:symbol)``` method if ```:symbol``` happens to be a reserved word (e.g., "key").

Most AR methods already handle this correctly, so calling ```Model.where(:key)``` does NOT fail
but ```Model.order(:key)``` does. This change impacts columns specified as symbols only.

This problem was originally reported as issue #2601. Tests pass.

Note to @tenderlove: it seems that this is something that could ultimately live within AREL, but based on what I saw the symbols are already strings and " ASC/DESC" is already attached to the column names before we get there. To be honest, after a few hours in the code I'm not completely clear as to where AR's intended responsibilities end and AREL's begin so if I'm missing something obvious pls inform.

PS - First Rails pull request so go easy on me... :)