rails
rails copied to clipboard
Ignore order of SQL joins, select, includes, left_outer_joins, eager_load and preload for ActiveRecord::Relation#or & for ActiveRecord::Relation#and
Summary
Fixes https://github.com/rails/rails/issues/45398
Ignore order of SQL joins, select, includes, left_outer_joins, eager_load and preload for ActiveRecord::Relation#or & for ActiveRecord::Relation#and
I haven't taken the time to actually invent examples, but my recollection is that ordering of left joins can affect the query results (at least, I have strong memories that the PostgreSQL optimizer is more limited in how it can reorder a LEFT JOIN-using query plan over an otherwise equivalent JOIN version). @sampatbadhe are you certain this is safe?
@matthewd Thank you for your review.
I haven't taken the time to actually invent examples, but my recollection is that ordering of left joins can affect the query results (at least, I have strong memories that the PostgreSQL optimizer is more limited in how it can reorder a LEFT JOIN-using query plan over an otherwise equivalent JOIN version). @sampatbadhe are you certain this is safe?
I'll re-verify with LEFT-JOIN on local and share the result.