Skip to content

Commit f3b83d0

Browse files
authored
Coerced some explain tests (#1183)
1 parent fb54157 commit f3b83d0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/cases/coerced_tests.rb

+27
Original file line numberDiff line numberDiff line change
@@ -2684,3 +2684,30 @@ def type_for_attribute_is_not_aware_of_custom_types_coerced
26842684
end
26852685
end
26862686
end
2687+
2688+
require "models/car"
2689+
class ExplainTest < ActiveRecord::TestCase
2690+
# Expected query slightly different from because of 'sp_executesql' and query parameters.
2691+
coerce_tests! :test_relation_explain_with_first
2692+
def test_relation_explain_with_first_coerced
2693+
expected_query = capture_sql {
2694+
Car.all.first
2695+
}.first[/EXEC sp_executesql N'(.*?) NEXT/, 1]
2696+
message = Car.all.explain.first
2697+
assert_match(/^EXPLAIN/, message)
2698+
assert_match(expected_query, message)
2699+
end
2700+
2701+
# Expected query slightly different from because of 'sp_executesql' and query parameters.
2702+
coerce_tests! :test_relation_explain_with_last
2703+
def test_relation_explain_with_last_coerced
2704+
expected_query = capture_sql {
2705+
Car.all.last
2706+
}.first[/EXEC sp_executesql N'(.*?) NEXT/, 1]
2707+
expected_query = expected_query
2708+
message = Car.all.explain.last
2709+
2710+
assert_match(/^EXPLAIN/, message)
2711+
assert_match(expected_query, message)
2712+
end
2713+
end

0 commit comments

Comments
 (0)