Open
Description
Not sure if this is the same issues as in #70 but eager loading the self_and_ancestors
association in Rails 4.1 generates invalid SQL.
Consider the following model:
class Category < ActiveRecord::Base
acts_as_tree
end
Attempting to run Category.includes(:self_and_ancestors).to_a
generates the following invalid SQL:
SELECT "categories".*
FROM "categories"
WHERE "categories"."id" IN (3, 2, 1)
ORDER BY "category_hierarchies".generations asc
This worked fine in Rails 4.0. A full test case can be found in https://gist.github.com/jturkel/82df7f9e4ccf96df14a5.
It looks like the problematic order
on the self_and_ancestors
relation is unnecessary in Rails 4.1 since the ActiveRecord::Associations::Preloader::ThroughAssociation preserves the order of the source association.