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

UnknownAttribute Exception when cloning documents containing deprecated attributes

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.0.0
    • Component/s: None
    • Labels:
      None
    • Sprint:
      Ruby Sprint 35

      Description

      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...

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: