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

The relation specified with the {{inverse_of}} option must have different name than relation which is about to be defined

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 7.0.0, 6.2.1
    • Affects Version/s: 6.2.0
    • Component/s: None
    • Labels:
      None

      Not sure which versions are precisely affected.

      See the attached file. One cannot define bi-directional relations like that:

      class Library
        include Mongoid::Document
        has_many :relation, class_name: "Book", inverse_of: :relation
      end
      
      class Book
        include Mongoid::Document
        belongs_to :relation, class_name: "Library", inverse_of: :relation
      end
      

      It results with inconsistent behaviour. On the assignment attempt, one side of the relation will not be saved, and sometimes stack overflow error may be raised.

        1. test.rb
          1.0 kB
        2. test.rb
          1.0 kB

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            skalee Sebastian Skalacki
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: