Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 6: Take and first use implicit ordering on identifier column #789

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,27 @@ def test_reverse_order_with_function_other_predicates_coerced
# We have implicit ordering, via FETCH.
coerce_tests! %r{doesn't have implicit ordering}

# We have implicit ordering, via FETCH.
coerce_tests! :test_reorder_with_take
def test_reorder_with_take_coerced
sql_log = capture_sql do
assert Post.order(:title).reorder(nil).take
end
assert sql_log.none? { |sql| /order by [posts].[title]/i.match?(sql) }, "ORDER BY title was used in the query: #{sql_log}"
assert sql_log.all? { |sql| /order by \[posts\]\.\[id\]/i.match?(sql) }, "default ORDER BY ID was not used in the query: #{sql_log}"
end

# We have implicit ordering, via FETCH.
coerce_tests! :test_reorder_with_first
def test_reorder_with_first_coerced
sql_log = capture_sql do
assert Post.order(:title).reorder(nil).first
end
assert sql_log.none? { |sql| /order by [posts].[title]/i.match?(sql) }, "ORDER BY title was used in the query: #{sql_log}"
assert sql_log.all? { |sql| /order by \[posts\]\.\[id\]/i.match?(sql) }, "default ORDER BY ID was not used in the query: #{sql_log}"
end


# We are not doing order duplicate removal anymore.
coerce_tests! :test_order_using_scoping

Expand Down