Skip to content

Commit b5c69a0

Browse files
committed
Take and first use implicit ordering on identifier column
1 parent 7026eb5 commit b5c69a0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,27 @@ def test_reverse_order_with_function_other_predicates_coerced
858858
# We have implicit ordering, via FETCH.
859859
coerce_tests! %r{doesn't have implicit ordering}
860860

861+
# We have implicit ordering, via FETCH.
862+
coerce_tests! :test_reorder_with_take_coerced
863+
def test_reorder_with_take
864+
sql_log = capture_sql do
865+
assert Post.order(:title).reorder(nil).take
866+
end
867+
assert sql_log.none? { |sql| /order by [posts].[title]/i.match?(sql) }, "ORDER BY title was used in the query: #{sql_log}"
868+
assert sql_log.all? { |sql| /order by \[posts\]\.\[id\]/i.match?(sql) }, "default ORDER BY ID was not used in the query: #{sql_log}"
869+
end
870+
871+
# We have implicit ordering, via FETCH.
872+
coerce_tests! :test_reorder_with_first_coerced
873+
def test_reorder_with_first_coerced
874+
sql_log = capture_sql do
875+
assert Post.order(:title).reorder(nil).first
876+
end
877+
assert sql_log.none? { |sql| /order by [posts].[title]/i.match?(sql) }, "ORDER BY title was used in the query: #{sql_log}"
878+
assert sql_log.all? { |sql| /order by \[posts\]\.\[id\]/i.match?(sql) }, "default ORDER BY ID was not used in the query: #{sql_log}"
879+
end
880+
881+
861882
# We are not doing order duplicate removal anymore.
862883
coerce_tests! :test_order_using_scoping
863884

0 commit comments

Comments
 (0)