Skip to content
This repository has been archived by the owner on Jul 14, 2020. It is now read-only.

Cannot add new field through lazy migration #195

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Cannot add new field through lazy migration #195

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Mar 11, 2015

It is not possible to add a new field to documents through the lazy migration feature.

If the field is not required, no error is thrown if the field is not in the document. Therefore, the migration is not applied.

If the field is required, a RequireFieldError is raised indicating that the new field is missing on the document. However, this error is not handled in the auto-migration logic

/mongokit/document.py

    235         if auto_migrate:
    236             error = None
    237             try:
    238                 super(Document, self).validate()
    239             except StructureError, e:
    240                 error = e
    241             except KeyError, e:
    242                 error = e
    243             except SchemaTypeError, e:
    244                 error = e
    245             if error:
    246                 if not self.migration_handler:
    247                     raise StructureError(str(error))
    248                 else:
    249                     # if we are here that's becose super.validate failed
    250                     # but it has processed custom type to bson.
    251                     self._migrate(process_to_bson=False)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

0 participants