mongoengine
mongoengine copied to clipboard
_document_registry relies on class name
Hi!
In case when there are two documents with the same classname one will be excluded from _document_registry
.
Some unwanted results may arise from this. For example GenericReferenceField
relies on get_document
, and after adding a duplicate document the old class will be overriden in registry by a new one. The old data will be dereferenced in new document.
Yes this is an issue - not sure of better alternatives
Maybe we can add some extra meta parameter? Some kind of documentId
, which will be a long random number or a sequence of characters. Document will be identified by pair of (documentId, ClassName)
The probability of getting same ids will be much smaller. In cases when we have problems with same ids we can provide some mechanism for overriding documentId
externally. (for example via settings.py)
This documentId
will be mondatory if "registry related" functionality is considered for future. Otherwise documents won't be added into registry. Or it's possible to have some default documentId
.
What do you think about this?