Skip to content

Commit dffe4aa

Browse files
Merge pull request rails#46471 from sampatbadhe/correct_in_order_of_example
Update ActiveRecord::QueryMethods#in_order_of example [ci-skip]
2 parents ed9f5e2 + 9d3fd35 commit dffe4aa

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

activerecord/lib/active_record/relation/query_methods.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,13 +512,16 @@ def order!(*args) # :nodoc:
512512
self
513513
end
514514

515-
# Allows to specify an order by a specific set of values. Depending on your
516-
# adapter this will either use a CASE statement or a built-in function.
515+
# Allows to specify an order by a specific set of values.
517516
#
518517
# User.in_order_of(:id, [1, 5, 3])
519518
# # SELECT "users".* FROM "users"
520-
# # ORDER BY FIELD("users"."id", 1, 5, 3)
521519
# # WHERE "users"."id" IN (1, 5, 3)
520+
# # ORDER BY CASE
521+
# # WHEN "users"."id" = 1 THEN 1
522+
# # WHEN "users"."id" = 5 THEN 2
523+
# # WHEN "users"."id" = 3 THEN 3
524+
# # END ASC
522525
#
523526
def in_order_of(column, values)
524527
klass.disallow_raw_sql!([column], permit: connection.column_name_with_order_matcher)

0 commit comments

Comments
 (0)