Open
Description
Given,
class Person
has_many :out, :knows, model_class: 'Person', type: nil
has_many :in, :posts, type: :posts
end
class Post
has_one :out, :owner, origin: :posts, model_class: 'Person'
end
Currently we only allow fixed length or infinite length paths in eager load like Person.where(id: [1,5,6]).with_association('knows*')
or Person.where(id: [1,5,6]).with_association('knows*4')
. If we want to eager load post on persons and the persons that they know, we have to do Person.where(id: [1,5,6]).with_association(['posts', 'knows*.posts'])
. This results in tow optional matches for person's posts and persons's know's posts. To avoid this we can have Person.where(id: [1,5,6]).with_association('knows*0...posts')
, which will result in only one optional match for posts, hence shorter and faster query.