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

Do not use relation_class_name for class comparisons

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Associations
    • Labels:

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              oleg.pudeyev Oleg Pudeyev
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: