• M
    Fix count which would sometimes force a DISTINCT · 0aae7806
    Maxime Lapointe 提交于
    The current behaviour of checking if there is a LEFT OUTER JOIN arel
    node to detect if we are doing eager_loading is wrong. This problem
    wasn't frequent before as only some pretty specific cases would add
    a LEFT OUTER JOIN arel node. However, the recent new feature
    left_outer_joins also add this node and made this problem happen
    frequently.
    
    Since in the perform_calculation function, we don't have access to
    eager_loading information, I had to extract the logic for the distinct
    out to the calculate method.
    
    As I was in the file for left_outer_join tests, I fixed a few that had
    bugs and I replaced some that were really weak with something that
    will catch more issues.
    
    In relation tests, the first test I changed would have failed if it
    had validated the hash returned by count instead of just checking how
    many pairs were in it. This is because this merge of join currently
    transforms the join node into an outer join node, which then made
    count do a distinct. So before this change, the return was
    {1=>1, 4=>1, 5=>1}.
    0aae7806
calculations.rb 13.7 KB