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

    • Task
    • Status: Closed
    • Resolution: Done
    • None
    • 4.0.0 final
    • None

    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

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

            Dates

              Created:
              Updated:
              Resolved: