mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

_document_registry relies on class name

Open yunmanger1 opened this issue 12 years ago • 2 comments

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.

yunmanger1 avatar Jun 02 '12 12:06 yunmanger1

Yes this is an issue - not sure of better alternatives

rozza avatar Jun 06 '12 19:06 rozza

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?

yunmanger1 avatar Jun 06 '12 19:06 yunmanger1