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

UnknownAttribute Exception when cloning documents containing deprecated attributes

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 6.0.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I'm not certain if this is newly intended behaviour, but now an UnknownAttribute exception is thrown whenever you call .clone on a document that contains deprecated data (that is, it was assigned data under an old schema containing that attribute, but the attribute has since been removed from the model).

      I find one of the major advantages of Mongo is the flexible data model that allows for easy changes to the schema while retaining deprecated data, so hopefully this isn't the intended behaviour! Explicitly including Dynamic::Attributes would solve the issue, but this would undesirably throw-away enforcement of the schema on new documents. IMO, when cloning old documents, the deprecated attributes should be copied or possibly silently ignored.

      This PR fixes the issue by copying them, but let me know if a different approach would be favourable...

            Assignee:
            Unassigned Unassigned
            Reporter:
            kmewhort kmewhort
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: