Skip to content

Commit 1a86372

Browse files
author
erdenezul
authored
Merge pull request #2011 from bagerard/fix_batch_size_qs_clone
Fix queryset batch_size that wasn't copied to cloned queryset
2 parents 50ffa80 + 9bd0d6b commit 1a86372

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Development
66
===========
77
- (Fill this out as you fix issues and develop your features).
88
- Fix .only() working improperly after using .count() of the same instance of QuerySet
9+
- Fix batch_size that was not copied when cloning a queryset object #2011
910
- POTENTIAL BREAKING CHANGE: All result fields are now passed, including internal fields (_cls, _id) when using `QuerySet.as_pymongo` #1976
1011
- Document a BREAKING CHANGE introduced in 0.15.3 and not reported at that time (#1995)
1112
- Fix InvalidStringData error when using modify on a BinaryField #1127

mongoengine/queryset/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ def _clone_into(self, new_qs):
757757
'_read_preference', '_iter', '_scalar', '_as_pymongo',
758758
'_limit', '_skip', '_hint', '_auto_dereference',
759759
'_search_text', 'only_fields', '_max_time_ms',
760-
'_comment')
760+
'_comment', '_batch_size')
761761

762762
for prop in copy_props:
763763
val = getattr(self, prop)

tests/queryset/queryset.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,16 @@ class A(Document):
394394
with self.assertRaises(ValueError):
395395
list(qs)
396396

397+
def test_batch_size_cloned(self):
398+
class A(Document):
399+
s = StringField()
400+
401+
# test that batch size gets cloned
402+
qs = A.objects.batch_size(5)
403+
self.assertEqual(qs._batch_size, 5)
404+
qs_clone = qs.clone()
405+
self.assertEqual(qs_clone._batch_size, 5)
406+
397407
def test_update_write_concern(self):
398408
"""Test that passing write_concern works"""
399409
self.Person.drop_collection()

0 commit comments

Comments
 (0)