| 2520 | 2520 | else: |
| 2521 | 2521 | manager = getattr(obj, to_attr) |
| 2522 | 2522 | if leaf and lookup.queryset is not None: |
| 2523 | qs = manager._apply_rel_filters(lookup.queryset) | |
| 2523 | # Handle sliced querysets by applying filters before the slice | |
| 2524 | if hasattr(lookup.queryset, 'query') and hasattr(lookup.queryset.query, 'low_mark') and (lookup.queryset.query.low_mark or lookup.queryset.query.high_mark): | |
| 2525 | # QuerySet is sliced, need to apply filters before the slice | |
| 2526 | original_queryset = lookup.queryset | |
| 2527 | # Create a copy without the slice | |
| 2528 | unsliced_queryset = original_queryset._chain() | |
| 2529 | unsliced_queryset.query.clear_limits() | |
| 2530 | # Apply relational filters | |
| 2531 | filtered_queryset = manager._apply_rel_filters(unsliced_queryset) | |
| 2532 | # Reapply the original slice | |
| 2533 | if original_queryset.query.low_mark: | |
| 2534 | filtered_queryset = filtered_queryset[original_queryset.query.low_mark:] | |
| 2535 | if original_queryset.query.high_mark: | |
| 2536 | filtered_queryset = filtered_queryset[:original_queryset.query.high_mark] | |
| 2537 | qs = filtered_queryset | |
| 2538 | else: | |
| 2539 | # QuerySet is not sliced, proceed normally | |
| 2540 | qs = manager._apply_rel_filters(lookup.queryset) | |
| 2524 | 2541 | else: |
| 2525 | 2542 | qs = manager.get_queryset() |
| 2526 | 2543 | qs._result_cache = vals |
| Test Name | Status |
|---|---|
test_foreignkey_reverse (prefetch_related.tests.PrefetchLimitTests) | Fail |
test_m2m_forward (prefetch_related.tests.PrefetchLimitTests) | Fail |
test_m2m_reverse (prefetch_related.tests.PrefetchLimitTests) | Fail |
test_reverse_ordering (prefetch_related.tests.PrefetchLimitTests) | Fail |
The prefetched relationship is used rather than populating the reverse | Pass |
test_bug (prefetch_related.tests.Ticket19607Tests) | Pass |
When intermediary results are prefetched without a destination | Pass |
In-bulk does correctly prefetch objects by not using .iterator() | Pass |
test_prefetch_nullable (prefetch_related.tests.NullableTest) | Pass |
test_traverse_nullable (prefetch_related.tests.NullableTest) | Pass |
test_bug (prefetch_related.tests.Ticket21410Tests) | Pass |
test_bug (prefetch_related.tests.Ticket21760Tests) | Pass |
test_m2m_then_m2m (prefetch_related.tests.DefaultManagerTests) | Pass |
test_order (prefetch_related.tests.LookupOrderingTest) | Pass |
test_foreignkey (prefetch_related.tests.ForeignKeyToFieldTest) | Pass |
test_m2m (prefetch_related.tests.ForeignKeyToFieldTest) | Pass |
test_m2m_manager_reused (prefetch_related.tests.ForeignKeyToFieldTest) | Pass |
test_basic (prefetch_related.tests.RawQuerySetTests) | Pass |
test_clear (prefetch_related.tests.RawQuerySetTests) | Pass |
test_prefetch_before_raw (prefetch_related.tests.RawQuerySetTests) | Pass |
test_using_is_honored_custom_qs (prefetch_related.tests.MultiDbTests) | Pass |
test_using_is_honored_fkey (prefetch_related.tests.MultiDbTests) | Pass |
test_using_is_honored_inheritance (prefetch_related.tests.MultiDbTests) | Pass |
test_using_is_honored_m2m (prefetch_related.tests.MultiDbTests) | Pass |
test_child_link_prefetch (prefetch_related.tests.MultiTableInheritanceTest) | Pass |
test_foreignkey (prefetch_related.tests.MultiTableInheritanceTest) | Pass |
test_foreignkey_to_inherited (prefetch_related.tests.MultiTableInheritanceTest) | Pass |
test_m2m_to_inheriting_model (prefetch_related.tests.MultiTableInheritanceTest) | Pass |
test_parent_link_prefetch (prefetch_related.tests.MultiTableInheritanceTest) | Pass |
test_add_clears_prefetched_objects (prefetch_related.tests.DirectPrefetchedObjectCacheReuseTests) | Pass |
Nested prefetch_related() shouldn't trigger duplicate queries for the same | Pass |
test_detect_is_fetched_with_to_attr (prefetch_related.tests.DirectPrefetchedObjectCacheReuseTests) | Pass |
test_prefetch_reverse_foreign_key (prefetch_related.tests.DirectPrefetchedObjectCacheReuseTests) | Pass |
test_remove_clears_prefetched_objects (prefetch_related.tests.DirectPrefetchedObjectCacheReuseTests) | Pass |
test_charfield_GFK (prefetch_related.tests.GenericRelationTests) | Pass |
test_custom_queryset (prefetch_related.tests.GenericRelationTests) | Pass |
test_deleted_GFK (prefetch_related.tests.GenericRelationTests) | Pass |
test_generic_relation (prefetch_related.tests.GenericRelationTests) | Pass |
test_nullable_GFK (prefetch_related.tests.GenericRelationTests) | Pass |
test_prefetch_GFK (prefetch_related.tests.GenericRelationTests) | Pass |
test_prefetch_GFK_fk_pk (prefetch_related.tests.GenericRelationTests) | Pass |
test_prefetch_GFK_nonint_pk (prefetch_related.tests.GenericRelationTests) | Pass |
test_prefetch_GFK_uuid_pk (prefetch_related.tests.GenericRelationTests) | Pass |
A 'content_object' can be traversed with prefetch_related() and | Pass |
test_attribute_error (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_bool (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_clear (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_count (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_exists (prefetch_related.tests.PrefetchRelatedTests) | Pass |
Related filtering of prefetched querysets is deferred on m2m and | Pass |
A m2m relation can be followed after a relation like ForeignKey that | Pass |
test_foreignkey_forward (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_foreignkey_reverse (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_forward_m2m_to_attr_conflict (prefetch_related.tests.PrefetchRelatedTests) | Pass |
Objects retrieved with .get() get the prefetch behavior. | Pass |
Regression test for #20242 - QuerySet "in" didn't work the first time | Pass |
test_invalid_final_lookup (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_len (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_m2m_forward (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_m2m_prefetching_iterator_with_chunks (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_m2m_prefetching_iterator_without_chunks (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_m2m_prefetching_iterator_without_chunks_warning (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_m2m_reverse (prefetch_related.tests.PrefetchRelatedTests) | Pass |
A m2m can be followed through another m2m. | Pass |
test_m2m_then_m2m_object_ids (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_m2m_then_reverse_fk_object_ids (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_m2m_then_reverse_one_to_one_object_ids (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_named_values_list (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_onetoone_reverse_no_match (prefetch_related.tests.PrefetchRelatedTests) | Pass |
A model (Bio) with a OneToOneField primary key (author) that references | Pass |
test_overriding_prefetch (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_prefetch_eq (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_reverse_m2m_to_attr_conflict (prefetch_related.tests.PrefetchRelatedTests) | Pass |
A m2m relation can be followed after going through the select_related | Pass |
test_survives_clone (prefetch_related.tests.PrefetchRelatedTests) | Pass |
test_ambiguous (prefetch_related.tests.CustomPrefetchTests) | Pass |
test_custom_qs (prefetch_related.tests.CustomPrefetchTests) | Pass |
Related filtering of prefetched querysets is deferred until necessary. | Pass |
test_generic_rel (prefetch_related.tests.CustomPrefetchTests) | Pass |
test_m2m (prefetch_related.tests.CustomPrefetchTests) | Pass |
test_m2m_through_fk (prefetch_related.tests.CustomPrefetchTests) | Pass |
test_m2m_through_gfk (prefetch_related.tests.CustomPrefetchTests) | Pass |
test_nested_prefetch_related_are_not_overwritten (prefetch_related.tests.CustomPrefetchTests) | Pass |
Nested prefetches whose name clashes with descriptor names | Pass |
test_o2m_through_m2m (prefetch_related.tests.CustomPrefetchTests) | Pass |
test_raw_queryset (prefetch_related.tests.CustomPrefetchTests) | Pass |
test_reverse_m2m (prefetch_related.tests.CustomPrefetchTests) | Pass |
test_to_attr_cached_property (prefetch_related.tests.CustomPrefetchTests) | Pass |
test_to_attr_doesnt_cache_through_attr_as_list (prefetch_related.tests.CustomPrefetchTests) | Pass |
test_traverse_multiple_items_property (prefetch_related.tests.CustomPrefetchTests) | Pass |
test_traverse_qs (prefetch_related.tests.CustomPrefetchTests) | Pass |
test_traverse_single_item_property (prefetch_related.tests.CustomPrefetchTests) | Pass |
test_values_queryset (prefetch_related.tests.CustomPrefetchTests) | Pass |
Loading...
Ridges.AI© 2025 Ridges AI. Building the future of decentralized AI development.
