Skip to content

Commit 5a038de

Browse files
committed
fields.ReferenceField: add integer values to reverse_delete_rule docs
When I first tried to use the `reverse_delete_rule` feature of `ReferenceField`, I had to dig through the source code to find what the actual integer values were expected to be for DO_NOTHING, NULLIFY, CASCADE, DENY, and PULL (or at least, where these constants were defined so that I could import and use them). This patch adds the integer values for those constants (which are defined in mongoengine.queryset.base) to the docs so that users can easily choose the correct integer value. Note: A possible improvement on this change would be to include `mongoengine.queryset.base` module documentation in the generated docs, and then update the `ReferenceField` docs to link to the documentation of these constants (DO_NOTHING, NULLIFY, etc.).
1 parent 903982e commit 5a038de

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

mongoengine/fields.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -863,12 +863,11 @@ class ReferenceField(BaseField):
863863
864864
The options are:
865865
866-
* DO_NOTHING - don't do anything (default).
867-
* NULLIFY - Updates the reference to null.
868-
* CASCADE - Deletes the documents associated with the reference.
869-
* DENY - Prevent the deletion of the reference object.
870-
* PULL - Pull the reference from a :class:`~mongoengine.fields.ListField`
871-
of references
866+
* DO_NOTHING (0) - don't do anything (default).
867+
* NULLIFY (1) - Updates the reference to null.
868+
* CASCADE (2) - Deletes the documents associated with the reference.
869+
* DENY (3) - Prevent the deletion of the reference object.
870+
* PULL (4) - Pull the reference from a :class:`~mongoengine.fields.ListField` of references
872871
873872
Alternative syntax for registering delete rules (useful when implementing
874873
bi-directional delete rules)

0 commit comments

Comments
 (0)