Skip to content

Commit 967c93e

Browse files
authored
Take and first use implicit ordering on identifier column (#789)
1 parent 0f9779e commit 967c93e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/cases/coerced_tests.rb

+21
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,27 @@ def test_reverse_order_with_function_other_predicates_coerced
878878
# We have implicit ordering, via FETCH.
879879
coerce_tests! %r{doesn't have implicit ordering}
880880

881+
# We have implicit ordering, via FETCH.
882+
coerce_tests! :test_reorder_with_take
883+
def test_reorder_with_take_coerced
884+
sql_log = capture_sql do
885+
assert Post.order(:title).reorder(nil).take
886+
end
887+
assert sql_log.none? { |sql| /order by [posts].[title]/i.match?(sql) }, "ORDER BY title was used in the query: #{sql_log}"
888+
assert sql_log.all? { |sql| /order by \[posts\]\.\[id\]/i.match?(sql) }, "default ORDER BY ID was not used in the query: #{sql_log}"
889+
end
890+
891+
# We have implicit ordering, via FETCH.
892+
coerce_tests! :test_reorder_with_first
893+
def test_reorder_with_first_coerced
894+
sql_log = capture_sql do
895+
assert Post.order(:title).reorder(nil).first
896+
end
897+
assert sql_log.none? { |sql| /order by [posts].[title]/i.match?(sql) }, "ORDER BY title was used in the query: #{sql_log}"
898+
assert sql_log.all? { |sql| /order by \[posts\]\.\[id\]/i.match?(sql) }, "default ORDER BY ID was not used in the query: #{sql_log}"
899+
end
900+
901+
881902
# We are not doing order duplicate removal anymore.
882903
coerce_tests! :test_order_using_scoping
883904

0 commit comments

Comments
 (0)