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

Remove redundant _type field declarations in child classes

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.2.0.rc1
    • Affects Version/s: None
    • Component/s: Attributes
    • None

      Currently Mongoid declares _type fields on the parent and each child when single collection inheritance is used. Each of these _type fields has a fixed default which is the class name that the field is declared on.

      Instead we could declare the field only on the parent class and use a Proc as the default value which would determine the correct value to write into the field at runtime based on the actual class that is being instantiated.

      Comments in the code refer to declaring fields in child classes for backwards compatibility, but either this would still happen or there isn't relevant test coverage that I can find.

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

              Created:
              Updated:
              Resolved: