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

Eager loading does two queries

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Whenever I eager load associations I see duplicate queries in my logs, with the second query including the included foreign key. Bug?

      blog = Blog.first
      posts = blog.posts.includes(:user).limit(10).to_a
      
      MONGODB mydb_development['posts'].find({:_id=>{"$in"=>[BSON::ObjectId('4f03bdb813a7734267000004'), BSON::ObjectId('4f03b66f13a7734267000002')]}})
      MONGODB mydb_development['posts'].find({:_id=>{"$in"=>[BSON::ObjectId('4f03bdb813a7734267000004'), BSON::ObjectId('4f03b66f13a7734267000002')]}}, {"user_id"=>1})
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            fbjork Fredrik Björk
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: