summaryrefslogtreecommitdiff
path: root/tests/prefetch_related/models.py
AgeCommit message (Collapse)Author
2026-03-18Fixed #36987 -- Observed prepared argument in UUIDField.get_db_prep_value().Jacob Walls
This avoids two isinstance() calls per UUID value.
2025-07-22Fixed #36282 -- Used prefetched values in ForwardManyToOneDescriptor from ↵Take Weiland
indirect ancestors. When looking for cached values in ManyRelatedManager and ForwardManyToOneDescriptor walk up the whole chain of ancestors (as long as they are cached) to find the prefetched relation.
2025-06-04Fixed #36432 -- Fixed a prefetch_related crash on related target subclass ↵Simon Charette
queryset. Regression in 626d77e52a3f247358514bcf51c761283968099c. Refs #36116. Thanks Cornelis Poppema for the excellent report.
2025-03-26Fixed #34819 -- Made GenericForeignKey prefetching use matching pk ↵Clifford Gama
representations. Ensured that rel_obj_attr and instance_attr return matching (pk, cls) tuples in GenericForeignKey.get_prefetch_queryset(), preventing mismatches when prefetching related objects where pk and get_prep_value() differ. Using value_to_string() also makes this code compatible with composite primary keys.
2025-02-06Fixed #35677 -- Avoided non-sticky filtering of prefetched many-to-many.Simon Charette
The original queryset._next_is_sticky() call never had the intended effect as no further filtering was applied internally after the pk__in lookup making it a noop. In order to be coherent with how related filters are applied when retrieving objects from a related manager the effects of what calling _next_is_sticky() prior to applying annotations and filters to the queryset provided for prefetching are emulated by allowing the reuse of all pre-existing JOINs. Thanks David Glenck and Thiago Bellini Ribeiro for the detailed reports and tests.
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2020-04-30Removed unused __str__() methods in tests models.Mariusz Felisiak
Follow up to 6461583b6cc257d25880ef9a9fd7e2125ac53ce1.
2020-02-04Simplified imports from django.db and django.contrib.gis.db.Nick Pope
2019-04-14Fixed #30343 -- Fixed prefetch_related() for GenericForeignKey when PK of ↵Mariusz Felisiak
related field is UUIDField.
2018-12-27Followed style guide for model attribute ordering.Matt Wiens
2018-02-05Refs #28723 -- Fixed stale prefetch_related cache after add/remove.Jon Dufresne
Regression in 514b2c989a948e3c59bda0da0c9427acf643cf5b.
2017-08-21Fixed #28375 -- Fixed KeyError crash on reverse prefetch of a model with ↵Paulo
OneToOneField primary key to a non-pk field.
2017-06-01Sorted imports per isort 4.2.9.Tim Graham
2017-04-19Fixed #28096 -- Allowed prefetch calls with ModelIterable subclassesClaude Paroz
Regression in 7ec330eeb96d0874949eacb8ed1bbb97e11807e1. Thanks Tim Graham for the review.
2017-01-25Refs #23919 -- Replaced super(ClassName, self) with super().chillaranand
2017-01-18Refs #23919 -- Removed python_2_unicode_compatible decorator usageClaude Paroz
2016-07-19Fixed #26916 -- Fixed prefetch_related when using a cached_property as to_attr.Simon Charette
Thanks Trac alias karyon for the report and Tim for the review.
2015-07-27Fixed #21127 -- Started deprecation toward requiring on_delete for ↵Flavio Curella
ForeignKey/OneToOneField
2015-06-15Fixed #24912 -- Fixed prefetch_related failure for UUIDField primary keysBrian King
This resolves a problem on databases besides PostgreSQL when using prefetch_related with a source model that uses a UUID primary key.
2015-02-06Fixed E265 comment styleCollin Anderson
2015-02-06Sorted imports with isort; refs #23860.Tim Graham
2014-05-21Fixed #22650 -- Fixed regression on prefetch_related.Loic Bistuer
Regression from f51c1f59 when using select_related then prefetch_related on the reverse side of an O2O: Author.objects.select_related('bio').prefetch_related('bio__books') Thanks Aymeric Augustin for the report and tests. Refs #17001.
2014-03-05Fixed #22207 -- Added support for GenericRelation reverse lookupsGabe Jackson
GenericRelation now supports an optional related_query_name argument. Setting related_query_name adds a relation from the related object back to the content type for filtering, ordering and other query operations. Thanks to Loic Bistuer for spotting a couple of important issues in his review.
2014-03-03Allowed custom querysets when prefetching single valued relationsLoic Bistuer
The original patch for custom prefetches didn't allow usage of custom queryset for single valued relations (along ForeignKey or OneToOneKey). Allowing these enables calling performance oriented queryset methods like select_related or defer/only. Thanks @akaariai and @timgraham for the reviews. Refs #17001.
2014-01-26Fixed #19774 -- Deprecated the contenttypes.generic module.Simon Charette
It contained models, forms and admin objects causing undesirable import side effects. Refs #16368. Thanks to Ramiro, Carl and Loïc for the review.
2013-11-13Fixed #21410 -- prefetch_related() for ForeignKeys with related_name='+'Loic Bistuer
Regression introduced by commit 9777442. Thanks to trac username troygrosfield for the report and test case.
2013-11-07Fixed #17001 -- Custom querysets for prefetch_related.Loic Bistuer
This patch introduces the Prefetch object which allows customizing prefetch operations. This enables things like filtering prefetched relations, calling select_related from a prefetched relation, or prefetching the same relation multiple times with different querysets. When a Prefetch instance specifies a to_attr argument, the result is stored in a list rather than a QuerySet. This has the fortunate consequence of being significantly faster. The preformance improvement is due to the fact that we save the costly creation of a QuerySet instance. Thanks @akaariai for the original patch and @bmispelon and @timgraham for the reviews.
2013-11-02Fixing E302 ErrorsJason Myers
Signed-off-by: Jason Myers <jason@jasonamyers.com>
2013-10-22Fixed E221 pep8 warnings.Tim Graham
2013-09-03Fixed "indentation is not a multiple of four" pep8 issues.Tim Graham
2013-05-24Fixed #19607 - prefetch_related crashLuke Plant
Thanks to av@rdf.ru and flarno11@yahoo.de for the report.
2013-03-08Fixed #15363 -- Renamed and normalized to `get_queryset` the methods that ↵Loic Bistuer
return a QuerySet.
2013-02-26Merged regressiontests and modeltests into the test root.Florian Apolloner