Ask Connection to quote symbolic column names when building ORDER BY #5029
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 failbut
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... :)