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

Do not use relation_class_name for class comparisons

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Associations

      Per the current documentation of relation_class_name, it should not be used for class comparisons. Yet Mongoid has several instances of this:

      lib/mongoid/association/embedded/embedded_in.rb:                  rel.relation_class_name == inverse_class_name
      lib/mongoid/association/embedded/embedded_in.rb:                rel.relation_class_name == inverse_class_name
      lib/mongoid/association/embedded/embeds_many.rb:                rel.relation_class_name == inverse_class_name
      lib/mongoid/association/embedded/embeds_one.rb:                rel.relation_class_name == inverse_class_name
      lib/mongoid/association/referenced/belongs_to.rb:                  rel.relation_class_name == inverse_class_name
      lib/mongoid/association/referenced/belongs_to.rb:                rel.relation_class_name == inverse_class_name
      lib/mongoid/association/referenced/has_and_belongs_to_many.rb:                rel.relation_class_name == inverse_class_name
      lib/mongoid/association/referenced/has_many.rb:                rel.relation_class_name == inverse_class_name
      lib/mongoid/association/referenced/has_one.rb:                rel.relation_class_name == inverse_class_name
      lib/mongoid/association/relatable.rb:        relation_class_name == other.relation_class_name &&
      

      The above code should be changed to use relation_class.

            Assignee:
            Unassigned Unassigned
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: