Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a result of the discussion at https://github.com/rails/rails/pull/14263/files#r10291489
- Loading branch information
Showing
2 changed files
with
25 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -275,15 +275,6 @@ def group!(*args) # :nodoc: | ||
|
|
||
# Allows to specify an order attribute: | # Allows to specify an order attribute: | ||
# | # | ||
# User.order('name') | |||
# => SELECT "users".* FROM "users" ORDER BY name | |||
# | |||
# User.order('name DESC') | |||
# => SELECT "users".* FROM "users" ORDER BY name DESC | |||
# | |||
# User.order('name DESC, email') | |||
# => SELECT "users".* FROM "users" ORDER BY name DESC, email | |||
# | |||
# User.order(:name) | # User.order(:name) | ||
# => SELECT "users".* FROM "users" ORDER BY "users"."name" ASC | # => SELECT "users".* FROM "users" ORDER BY "users"."name" ASC | ||
# | # | ||
|
@@ -292,6 +283,15 @@ def group!(*args) # :nodoc: | ||
# | # | ||
# User.order(:name, email: :desc) | # User.order(:name, email: :desc) | ||
# => SELECT "users".* FROM "users" ORDER BY "users"."name" ASC, "users"."email" DESC | # => SELECT "users".* FROM "users" ORDER BY "users"."name" ASC, "users"."email" DESC | ||
# | |||
# User.order('name') | |||
# => SELECT "users".* FROM "users" ORDER BY name | |||
# | |||
# User.order('name DESC') | |||
# => SELECT "users".* FROM "users" ORDER BY name DESC | |||
# | |||
# User.order('name DESC, email') | |||
# => SELECT "users".* FROM "users" ORDER BY name DESC, email | |||
def order(*args) | def order(*args) | ||
check_if_method_has_arguments!(:order, args) | check_if_method_has_arguments!(:order, args) | ||
spawn.order!(*args) | spawn.order!(*args) | ||
|
@@ -1030,13 +1030,14 @@ def build_order(arel) | ||
arel.order(*orders) unless orders.empty? | arel.order(*orders) unless orders.empty? | ||
end | end | ||
|
|
||
VALID_DIRECTIONS = [:asc, :desc, 'asc', 'desc'] # :nodoc: | VALID_DIRECTIONS = [:asc, :desc, :ASC, :DESC, | ||
'asc', 'desc', 'ASC', 'DESC'] # :nodoc: | |||
|
|
||
def validate_order_args(args) | def validate_order_args(args) | ||
args.grep(Hash) do |h| | args.grep(Hash) do |h| | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
senny
Author
Member
|
|||
h.values.map(&:downcase).each do |value| | h.values.each do |value| | ||
This comment has been minimized.
Sorry, something went wrong.
bogdan
Contributor
|
|||
raise ArgumentError, "Direction '#{value}' is invalid. Valid " \ | raise ArgumentError, "Direction \"#{value}\" is invalid. Valid " \ | ||
"directions are asc and desc." unless VALID_DIRECTIONS.include?(value) | "directions are: #{VALID_DIRECTIONS.inspect}" unless VALID_DIRECTIONS.include?(value) | ||
end | end | ||
end | end | ||
end | end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit f6aeb8b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more intermediate Array here.
While Aaron is putting hard work to make it adequate ... we are keeping our inadequate staff in master.