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

Issue with default_scope and eager loading

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 2.4.10
    • Component/s: None
    • Labels:
      None

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: