@@ -310,6 +310,29 @@ def test_array_as_rhs(self):
310
310
)
311
311
self .assertCountEqual (result , [self .new_descoveries ])
312
312
313
+ def test_array_annotation_as_rhs (self ):
314
+ result = Exhibit .objects .annotate (
315
+ section_numbers = models .F ("main_section__section_number" )
316
+ ).filter (section_numbers__in = models .F ("sections__section_number" ))
317
+ self .assertCountEqual (result , [self .new_descoveries ])
318
+
319
+ def test_array_annotation_index (self ):
320
+ # This test would be useful to have, but it cannot be implemented
321
+ # due to the current annotation handling.
322
+ # Supporting slicing or indexing over an annotated
323
+ # Embedded Array Field would require a refactor.
324
+ result = Exhibit .objects .annotate (
325
+ section_numbers = models .F ("sections__section_number" )
326
+ ).filter (section_numbers__0 = 1 )
327
+ self .assertCountEqual (result , [self .new_descoveries , self .egypt ])
328
+
329
+ def test_array_annotation (self ):
330
+ results = Exhibit .objects .annotate (
331
+ section_numbers = models .F ("sections__section_number" )
332
+ ).all ()
333
+ sections_numbers = [e .section_numbers for e in results ]
334
+ self .assertCountEqual (sections_numbers , [[1 ], [1 , 2 ], [2 ], []])
335
+
313
336
314
337
@isolate_apps ("model_fields_" )
315
338
class CheckTests (SimpleTestCase ):
0 commit comments