Merge pull request #1 from thedrow/patch-1
Added a test that verifies distinct operations on nested embedded docume...
This commit is contained in:
commit
d58f3b7520
@ -2879,9 +2879,12 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
self.assertEqual(authors, [mark_twain, john_tolkien])
|
self.assertEqual(authors, [mark_twain, john_tolkien])
|
||||||
|
|
||||||
def test_distinct_ListField_EmbeddedDocumentField_EmbeddedDocumentField(self):
|
def test_distinct_ListField_EmbeddedDocumentField_EmbeddedDocumentField(self):
|
||||||
|
class Continent(EmbeddedDocument):
|
||||||
|
continent_name = StringField()
|
||||||
|
|
||||||
class Country(EmbeddedDocument):
|
class Country(EmbeddedDocument):
|
||||||
country_name = StringField()
|
country_name = StringField()
|
||||||
|
continent = EmbeddedDocumentField(Continent)
|
||||||
|
|
||||||
class Author(EmbeddedDocument):
|
class Author(EmbeddedDocument):
|
||||||
name = StringField()
|
name = StringField()
|
||||||
@ -2893,8 +2896,11 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
|
|
||||||
Book.drop_collection()
|
Book.drop_collection()
|
||||||
|
|
||||||
scotland = Country(country_name="Scotland")
|
europe = Continent(continent_name='europe')
|
||||||
tibet = Country(country_name="Tibet")
|
asia = Continent(continent_name='asia')
|
||||||
|
|
||||||
|
scotland = Country(country_name="Scotland", continent=europe)
|
||||||
|
tibet = Country(country_name="Tibet", continent=asia)
|
||||||
|
|
||||||
mark_twain = Author(name="Mark Twain", country=scotland)
|
mark_twain = Author(name="Mark Twain", country=scotland)
|
||||||
john_tolkien = Author(name="John Ronald Reuel Tolkien", country=tibet)
|
john_tolkien = Author(name="John Ronald Reuel Tolkien", country=tibet)
|
||||||
@ -2908,6 +2914,10 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(country_list, [scotland, tibet])
|
self.assertEqual(country_list, [scotland, tibet])
|
||||||
|
|
||||||
|
continent_list = Book.objects.distinct("authors.country.continent")
|
||||||
|
|
||||||
|
self.assertEqual(continent_list, [asia, europe])
|
||||||
|
|
||||||
def test_distinct_ListField_ReferenceField(self):
|
def test_distinct_ListField_ReferenceField(self):
|
||||||
class Foo(Document):
|
class Foo(Document):
|
||||||
bar_lst = ListField(ReferenceField('Bar'))
|
bar_lst = ListField(ReferenceField('Bar'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user