Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement lazy assignment for Reverse Delete Rules (aka the NotRegistered exception) #2764

Open
combscCode opened this issue Jul 27, 2023 · 0 comments

Comments

@combscCode
Copy link

MongoEngine will throw a NotRegistered exception when a user tries to register a delete rule on a Document that hasn't been defined yet. This is because the delete rule is stored directly on the Document class, so attempting to access the Document through get_document throws an exception. Rather than immediately throwing an exception, MongoEngine should just store the delete rule and lazily assign it to the Document once it is defined.

Fixing this issue will allow users to define bi-directional delete rules (this can currently be done by defining delete rules at runtime, but this behavior is not documented well). It also decouples delete rules from import ordering, which created a problem for my project that uses mongoengine.

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

No branches or pull requests

1 participant