Skip to content

Coerced some explain tests #1183

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

Merged
merged 1 commit into from
May 20, 2024
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
27 changes: 27 additions & 0 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2684,3 +2684,30 @@ def type_for_attribute_is_not_aware_of_custom_types_coerced
end
end
end

require "models/car"
class ExplainTest < ActiveRecord::TestCase
# Expected query slightly different from because of 'sp_executesql' and query parameters.
coerce_tests! :test_relation_explain_with_first
def test_relation_explain_with_first_coerced
expected_query = capture_sql {
Car.all.first
}.first[/EXEC sp_executesql N'(.*?) NEXT/, 1]
message = Car.all.explain.first
assert_match(/^EXPLAIN/, message)
assert_match(expected_query, message)
end

# Expected query slightly different from because of 'sp_executesql' and query parameters.
coerce_tests! :test_relation_explain_with_last
def test_relation_explain_with_last_coerced
expected_query = capture_sql {
Car.all.last
}.first[/EXEC sp_executesql N'(.*?) NEXT/, 1]
expected_query = expected_query
message = Car.all.explain.last

assert_match(/^EXPLAIN/, message)
assert_match(expected_query, message)
end
end
Loading