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

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

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

      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
      

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

              Created:
              Updated:
              Resolved: