Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1988

Issue with default_scope and eager loading

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.4.10
    • Affects Version/s: None
    • Component/s: None
    • None

      I have a Blog model like:

      class Blog
      has_many :posts
      default_scope includes(:posts)
      end

      so that posts are eagerly loaded when a Blog query is made.

      I experience unexpected behaviour if I query for the same blog > 1 times. It seems like the post data are reapplied to the array, so that the array contains duplicates of the posts.

      Is this expected behaviour?

      Please let me know if you need more info.

            Assignee:
            Unassigned Unassigned
            Reporter:
            stantona stantona
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: