@@ -136,6 +136,15 @@ def test_order_and_group_by_embedded_field(self):
136136 ],
137137 )
138138
139+ def test_range_query (self ):
140+ sorted_obj = sorted (self .objs , key = lambda x : x .data .auto_now )
141+ queryset = Holder .objects .filter (
142+ data__auto_now__range = (sorted_obj [2 ].data .auto_now , sorted_obj [- 1 ].data .auto_now )
143+ ).order_by ("data__integer" )
144+ self .assertEqual (queryset .count (), 4 )
145+ expected_objs = sorted (e .data .integer for e in sorted_obj [2 :])
146+ self .assertQuerySetEqual (queryset , expected_objs , lambda h : h .data .integer )
147+
139148 def test_order_and_group_by_embedded_field_annotation (self ):
140149 # Create repeated `data__integer` values.
141150 [Holder .objects .create (data = Data (integer = x )) for x in range (6 )]
@@ -223,6 +232,7 @@ class MyModel(models.Model):
223232 "Embedded models must be a subclass of django_mongodb_backend.models.EmbeddedModel." ,
224233 )
225234
235+
226236class SubqueryExistsTests (TestCase ):
227237 def setUpTestData (self ):
228238 # Create test data
@@ -259,11 +269,6 @@ def test_in_subquery(self):
259269 self .assertEqual (queryset .count (), 3 )
260270 self .assertQuerySetEqual (queryset , ["Book 2" , "Book 3" , "Book 4" ], lambda book : book .name )
261271
262- def test_range_query (self ):
263- queryset = Book .objects .filter (author__age__range = (25 , 30 )).order_by ("author__name" )
264- self .assertEqual (queryset .count (), 2 )
265- self .assertQuerySetEqual (queryset , ["Alice" , "Alice" ], lambda book : book .author .name )
266-
267272 def test_exists_with_foreign_object (self ):
268273 subquery = Library .objects .filter (best_seller = OuterRef ("name" ))
269274 queryset = Book .objects .filter (Exists (subquery ))
0 commit comments