-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
[BUG] validate_on_save
doesn't work with Document.save()
#664
Comments
Try adding
Make sure you import I looked on this test file and you'll need to implement this because the base Document class doesn't have the action run for saving and only for creation. Let me know if it works. |
@jakeecolution No, it doesn't work. If we add this decorator to a @after_event(ValidateOnSave)
async def validate_self(self, *args, **kwargs):
print("Calling validate_self()")
await super().validate_self(*args, **kwargs) we get infinite recursion:
If we remove the parent method call: @after_event(ValidateOnSave)
async def validate_self(self, *args, **kwargs):
print("Calling validate_self()")
# await super().validate_self(*args, **kwargs) it will only work on creation, just like before:
It turns out that |
Thank you for the catch. Fixed in the PR: #669 |
This issue is stale because it has been open 30 days with no activity. |
This issue was closed because it has been stalled for 14 days with no activity. |
Describe the bug
The documentation says that
validate_on_save
is triggered before any type of document saving (insert, replace, save, save_changes). However, it does not work when usingsave()
.To Reproduce
Dependencies:
Code for tests:
Output:
Expected behavior
Output:
Additional context
Same problem on an older version (beanie==1.19.2).
The text was updated successfully, but these errors were encountered: