Fix relation merger issue with `left_outer_joins`.
#27860

meinac wants to merge meinac:fix_left_joins_behaviour_with_merge into rails:master

We do not currently have an analysis of these two commits