parent
403977cd49
commit
a6948771d8
1
AUTHORS
1
AUTHORS
@ -84,3 +84,4 @@ that much better:
|
|||||||
* dave mankoff
|
* dave mankoff
|
||||||
* Alexander G. Morano
|
* Alexander G. Morano
|
||||||
* jwilder
|
* jwilder
|
||||||
|
* Joe Shaw
|
||||||
|
@ -5,6 +5,7 @@ Changelog
|
|||||||
Changes in dev
|
Changes in dev
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
- Added support for DBRefs in distinct()
|
||||||
- Fixed issue saving False booleans
|
- Fixed issue saving False booleans
|
||||||
- Fixed issue with dynamic documents deltas
|
- Fixed issue with dynamic documents deltas
|
||||||
- Added Reverse Delete Rule support to ListFields - MapFields aren't supported
|
- Added Reverse Delete Rule support to ListFields - MapFields aren't supported
|
||||||
|
@ -1073,8 +1073,10 @@ class QuerySet(object):
|
|||||||
:param field: the field to select distinct values from
|
:param field: the field to select distinct values from
|
||||||
|
|
||||||
.. versionadded:: 0.4
|
.. versionadded:: 0.4
|
||||||
|
.. versionchanged:: 0.5 - Fixed handling references
|
||||||
"""
|
"""
|
||||||
return self._cursor.distinct(field)
|
from dereference import dereference
|
||||||
|
return dereference(self._cursor.distinct(field), 1)
|
||||||
|
|
||||||
def only(self, *fields):
|
def only(self, *fields):
|
||||||
"""Load only a subset of this document's fields. ::
|
"""Load only a subset of this document's fields. ::
|
||||||
|
@ -1958,6 +1958,24 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
self.assertEqual(set(self.Person.objects(age=30).distinct('name')),
|
self.assertEqual(set(self.Person.objects(age=30).distinct('name')),
|
||||||
set(['Mr Orange', 'Mr Pink']))
|
set(['Mr Orange', 'Mr Pink']))
|
||||||
|
|
||||||
|
def test_distinct_handles_references(self):
|
||||||
|
class Foo(Document):
|
||||||
|
bar = ReferenceField("Bar")
|
||||||
|
|
||||||
|
class Bar(Document):
|
||||||
|
text = StringField()
|
||||||
|
|
||||||
|
Bar.drop_collection()
|
||||||
|
Foo.drop_collection()
|
||||||
|
|
||||||
|
bar = Bar(text="hi")
|
||||||
|
bar.save()
|
||||||
|
|
||||||
|
foo = Foo(bar=bar)
|
||||||
|
foo.save()
|
||||||
|
|
||||||
|
self.assertEquals(Foo.objects.distinct("bar"), [bar])
|
||||||
|
|
||||||
def test_custom_manager(self):
|
def test_custom_manager(self):
|
||||||
"""Ensure that custom QuerySetManager instances work as expected.
|
"""Ensure that custom QuerySetManager instances work as expected.
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user