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

reserved attribute names for embedded relations conflict with document structure

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 7.0.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      class Optometry::Procedures::Recipe::Base
        embeds_one :final_prescription, class_name: 'Optometry::Prescriptions::Final'
      end
      
      class Optometry::Prescriptions::Final < Optometry::Prescriptions::Base
        # OculiUterque is a representation of a common structure for our domain
        # 'base' is a real term for our business domain
        embeds_one :base, class_name: 'Optometry::Procedures::OculiUterque'
        embedded_in :examination, class_name: 'Optometry::Procedures::Recipe::Base'
      end
      
      Optometry::Prescriptions::Final.new.base.class
      # => Optometry::Procedures::Recipe::Base
      
      

      when I invoke base on the Optometry::Prescriptions::Base instance I expected to receive a Optometry::Procedures::OculiUterque instance. Is it possible that in the future Mongoid put a prefix (like an underscore) for avoiding this scenario in which you have a correct term in the business domain but you can't use it because of a reserved word?, also base, metadata and target seem common words for whatever context you have, my suggestion is to use _base, _metadata or _target instead. Mongoid uses it for inheritance (_type)

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            johaned Johan Tique
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: