Merge pull request #2519 from bagerard/bugfix_qs_property
Fix instance._qs that was failing due to bad parametrization that went unnoticed
This commit is contained in:
commit
cc85165b0c
@ -574,7 +574,7 @@ class Document(BaseDocument, metaclass=TopLevelDocumentMetaclass):
|
|||||||
def _qs(self):
|
def _qs(self):
|
||||||
"""Return the default queryset corresponding to this document."""
|
"""Return the default queryset corresponding to this document."""
|
||||||
if not hasattr(self, "__objects"):
|
if not hasattr(self, "__objects"):
|
||||||
self.__objects = QuerySet(self, self._get_collection())
|
self.__objects = QuerySet(self.__class__, self._get_collection())
|
||||||
return self.__objects
|
return self.__objects
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -407,6 +407,16 @@ class TestDocumentInstance(MongoDBTestCase):
|
|||||||
assert person.name == "Test User"
|
assert person.name == "Test User"
|
||||||
assert person.age == 30
|
assert person.age == 30
|
||||||
|
|
||||||
|
def test__qs_property_does_not_raise(self):
|
||||||
|
# ensures no regression of #2500
|
||||||
|
class MyDocument(Document):
|
||||||
|
pass
|
||||||
|
|
||||||
|
MyDocument.drop_collection()
|
||||||
|
object = MyDocument()
|
||||||
|
object._qs().insert([MyDocument()])
|
||||||
|
assert MyDocument.objects.count() == 1
|
||||||
|
|
||||||
def test_to_dbref(self):
|
def test_to_dbref(self):
|
||||||
"""Ensure that you can get a dbref of a document."""
|
"""Ensure that you can get a dbref of a document."""
|
||||||
person = self.Person(name="Test User", age=30)
|
person = self.Person(name="Test User", age=30)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user