Querysets now utilises a local cache
Changed __len__ behavour in the queryset (#247, #311)
This commit is contained in:
@@ -4,6 +4,8 @@ Changelog
|
||||
|
||||
Changes in 0.8.0
|
||||
================
|
||||
- Querysets now utilises a local cache
|
||||
- Changed __len__ behavour in the queryset (#247, #311)
|
||||
- Fixed querying string versions of ObjectIds issue with ReferenceField (#307)
|
||||
- Added $setOnInsert support for upserts (#308)
|
||||
- Upserts now possible with just query parameters (#309)
|
||||
@@ -25,7 +27,6 @@ Changes in 0.8.0
|
||||
- Added SequenceField.set_next_value(value) helper (#159)
|
||||
- Updated .only() behaviour - now like exclude it is chainable (#202)
|
||||
- Added with_limit_and_skip support to count() (#235)
|
||||
- Removed __len__ from queryset (#247)
|
||||
- Objects queryset manager now inherited (#256)
|
||||
- Updated connection to use MongoClient (#262, #274)
|
||||
- Fixed db_alias and inherited Documents (#143)
|
||||
|
||||
@@ -235,12 +235,15 @@ update your code like so: ::
|
||||
mammals = Animal.objects(type="mammal").filter(order="Carnivora") # The final queryset is assgined to mammals
|
||||
[m for m in mammals] # This will return all carnivores
|
||||
|
||||
No more len
|
||||
-----------
|
||||
Len iterates the queryset
|
||||
--------------------------
|
||||
|
||||
If you ever did len(queryset) it previously did a count() under the covers, this
|
||||
caused some unusual issues - so now it has been removed in favour of the
|
||||
explicit `queryset.count()` to update::
|
||||
If you ever did `len(queryset)` it previously did a `count()` under the covers,
|
||||
this caused some unusual issues. As `len(queryset)` is most often used by
|
||||
`list(queryset)` we now cache the queryset results and use that for the length.
|
||||
|
||||
This isn't as performant as a `count()` and if you aren't iterating the
|
||||
queryset you should upgrade to use count::
|
||||
|
||||
# Old code
|
||||
len(Animal.objects(type="mammal"))
|
||||
|
||||
Reference in New Issue
Block a user