File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
tests/regressiontests/mongodb Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 1
1
from pymongo import ASCENDING , DESCENDING
2
2
3
- from django .db .models .sql .datastructures import FullResultSet
3
+ from django .db .models .sql .datastructures import FullResultSet , EmptyResultSet
4
4
5
5
6
6
# TODO: ...
@@ -87,11 +87,16 @@ def build_query(self, aggregates=False):
87
87
if self .query .low_mark :
88
88
cursor = cursor .skip (self .query .low_mark )
89
89
if self .query .high_mark is not None :
90
+ if self .query .high_mark - self .query .low_mark == 0 :
91
+ raise EmptyResultSet
90
92
cursor = cursor .limit (self .query .high_mark - self .query .low_mark )
91
93
return cursor
92
94
93
95
def results_iter (self ):
94
- query = self .build_query ()
96
+ try :
97
+ query = self .build_query ()
98
+ except EmptyResultSet :
99
+ return
95
100
fields = self .get_fields (aggregates = False )
96
101
if fields is None :
97
102
fields = [
Original file line number Diff line number Diff line change @@ -95,8 +95,7 @@ def test_slicing(self):
95
95
]
96
96
97
97
for i in xrange (5 ):
98
- # TODO: should be i, but Mongo falls over with limit(0)
99
- for j in xrange (i + 1 , 5 ):
98
+ for j in xrange (i , 5 ):
100
99
self .assertQuerysetEqual (
101
100
Artist .objects .all ()[i :j ],
102
101
artists [i :j ],
You can’t perform that action at this time.
0 commit comments