Details
-
Task
-
Status: Closed
-
Major - P3
-
Resolution: Gone away
-
None
-
None
Description
I'm seeing this behavior in mongoid 3 when using eager loading with default scopes. I'm not sure if it's a bug or by design.
Simple example:
class Person |
include Mongoid::Document
|
field :name |
has_many :hobbies |
end |
class Hobby |
include Mongoid::Document
|
field :name |
field :status |
belongs_to :person |
default_scope where(:status.ne => 'deleted') |
end |
After creating a person and two hobbies, one of them with status = 'deleted', person = Person.includes(:hobbies).first correctly performs the eager load query (including the default scope), but then person.hobbies hits the database again. Removing the default scope causes it to work as expected.