• M
    Keep INNER JOIN when merging relations · 249ddd0c
    Maxime Lapointe 提交于
    Doing `Author.joins(:posts).merge(Post.joins(:comments))` does this
    `SELECT ... INNER JOIN posts ON... LEFT OUTER JOIN comments ON...`
    instead of doing
    `SELECT ... INNER JOIN posts ON... INNER JOIN comments ON...`.
    
    This behavior is unexpected and makes little sense as, basically, doing
    `Post.joins(:comments)` means I want posts that have comments. Turning
    it to a LEFT JOIN means I want posts and join the comments data, if
    any.
    
    We can see this problem directly in the existing tests.
    The test_relation_merging_with_merged_joins_as_symbols only does joins
    from posts to comments to ratings while the ratings fixture isn't
    loaded, but the count is non-zero.
    249ddd0c
relation_test.rb 12.1 KB