File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -2684,3 +2684,30 @@ def type_for_attribute_is_not_aware_of_custom_types_coerced
2684
2684
end
2685
2685
end
2686
2686
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
You can’t perform that action at this time.
0 commit comments