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

has_and_belongs_to_many does not use eager loading with { inverse_of: nil }

    XMLWordPrintable

    Details

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

      Description

      class Car
        include Mongoid::Document
      end
       
      class Person
        include Mongoid::Document
        has_and_belongs_to_many :cars, inverse_of: nil
      end
       
      Car.delete_all
      Person.delete_all
       
      person = Person.create!
       
      10.times do |i|
        person.cars << Car.create!
      end
       
      person = Person.includes( :cars ).first
       
      # cars are not loaded 
      # person.ivar( :cars ) === false
      

        Attachments

          Activity

            People

            Assignee:
            arthurnn Arthur Nogueira Neves
            Reporter:
            xronos-i-am xronos-i-am
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: