File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -742,6 +742,24 @@ def test_reverse_arel_assoc_order_with_function_coerced
742742 end
743743end
744744
745+ class ActiveRecord ::RelationTest < ActiveRecord ::TestCase
746+ coerce_tests! :test_relation_merging_with_merged_symbol_joins_is_aliased
747+ def test_relation_merging_with_merged_symbol_joins_is_aliased__coerced
748+ categorizations_with_authors = Categorization . joins ( :author )
749+ queries = capture_sql { Post . joins ( :author , :categorizations ) . merge ( Author . select ( :id ) ) . merge ( categorizations_with_authors ) . to_a }
750+
751+ nb_inner_join = queries . sum { |sql | sql . scan ( /INNER\s +JOIN/i ) . size }
752+ assert_equal 3 , nb_inner_join , "Wrong amount of INNER JOIN in query"
753+
754+ # using `\W` as the column separator
755+ query_matches = queries . any? do |sql |
756+ %r[INNER\s +JOIN\s +#{ Regexp . escape ( Author . quoted_table_name ) } \s +\W authors_categorizations\W ]i . match? ( sql )
757+ end
758+
759+ assert query_matches , "Should be aliasing the child INNER JOINs in query"
760+ end
761+ end
762+
745763
746764
747765
You can’t perform that action at this time.
0 commit comments