Commit Graph

85 Commits

Author SHA1 Message Date
Alex Aktsipetrov 681f7e2b13 Fixed #20577 -- Deferred filtering of prefetched related querysets.
Added internal interface to QuerySet that allows to defer next filter
call till .query is accessed. Used it to optimize prefetch_related().

Thanks Simon Charette for the review.
2019-10-21 13:21:54 +02:00
ElizabethU 54ea290e5b Fixed #30651 -- Made __eq__() methods return NotImplemented for not implemented comparisons.
Changed __eq__ to return NotImplemented instead of False if compared to
an object of the same type, as is recommended by the Python data model
reference. Now these models can be compared to ANY (or other objects
with __eq__ overwritten) without returning False automatically.
2019-10-01 17:58:19 +02:00
Mariusz Felisiak 6475e6318c Refs #30651 -- Added tests for Prefetch.__eq__(). 2019-10-01 17:35:55 +02:00
Tim Gates 6b402b28b3 Fixed typo in tests/prefetch_related/tests.py comment. 2019-08-26 08:14:29 +02:00
Min ho Kim 7bd9633320 Fixed typos in test names and a comment. 2019-08-23 10:46:43 +02:00
Iain Watts 59ffafa1d2 Fixed #30482 -- Prevented unnecessary evaluation of lookup.queryset in prefetch_related_objects(). 2019-05-16 21:39:55 +02:00
Vinny Do a4055adf70 Fixed #30368 -- Fixed prefetch_related() for GenericForeignKey when PK is also a FK. 2019-04-16 09:49:16 +02:00
Mariusz Felisiak 1afbc96a75
Fixed #30343 -- Fixed prefetch_related() for GenericForeignKey when PK of related field is UUIDField. 2019-04-14 10:02:59 +02:00
Simon Charette 8c775391b7 Refs #28478 -- Deprecated TestCase's allow_database_queries and multi_db in favor of databases. 2019-01-10 19:11:21 -05:00
Matt Wiens e817ae74da Followed style guide for model attribute ordering. 2018-12-27 19:34:14 -05:00
Paulo 6104875a2c Fixed #29230 -- Fixed nested prefetches that clash with descriptors. 2018-05-27 21:45:51 -04:00
Adnan Umer 534d8d875e Fixed #28600 -- Added prefetch_related() support to RawQuerySet. 2018-04-19 13:48:27 -04:00
Jon Dufresne 8b21878357 Refs #28723 -- Fixed stale prefetch_related cache after add/remove.
Regression in 514b2c989a.
2018-02-05 11:02:57 -05:00
Jon Dufresne f0658ff818 Made prefetch_related tests use assertCountEqual() for unordered sequences. 2018-02-05 10:00:57 -05:00
Mike Hansen 514b2c989a Fixed #28723 -- Fixed RelatedManager's prefetch_related() cache name. 2017-11-02 10:06:00 -04:00
Paulo fea9cb46aa Fixed #28375 -- Fixed KeyError crash on reverse prefetch of a model with OneToOneField primary key to a non-pk field. 2017-08-21 16:14:13 -04:00
Mads Jensen a51c4de194 Used assertRaisesMessage() to test Django's error messages. 2017-07-29 19:07:23 -04:00
Jon Dufresne 2c69824e5a Refs #23968 -- Removed unnecessary lists, generators, and tuple calls. 2017-06-01 19:08:59 -04:00
Tim Graham cde31daf88 Sorted imports per isort 4.2.9. 2017-06-01 13:23:48 -04:00
François Freitag ec05ff086c Refs #25546 -- Added detailed comments for prefetch_related test. 2017-05-04 09:19:54 -04:00
François Freitag c0a2b9508a Fixed #27554 -- Fixed prefetch_related() crash when fetching relations in nested Prefetches. 2017-05-04 09:17:29 -04:00
Claude Paroz 43b4a1618e Fixed #28096 -- Allowed prefetch calls with ModelIterable subclasses
Regression in 7ec330eeb9.
Thanks Tim Graham for the review.
2017-04-19 19:32:46 +02:00
Tim Graham 6b4f018b2b Replaced type-specific assertions with assertEqual().
Python docs say, "it's usually not necessary to invoke these methods directly."
2017-03-17 07:51:48 -04:00
chillaranand d6eaf7c018 Refs #23919 -- Replaced super(ClassName, self) with super(). 2017-01-25 12:23:46 -05:00
Claude Paroz 2366100872 Removed unneeded force_text calls in the test suite 2017-01-24 18:45:54 +01:00
Claude Paroz 7b2f2e74ad Refs #23919 -- Removed six.<various>_types usage
Thanks Tim Graham and Simon Charette for the reviews.
2017-01-18 20:18:46 +01:00
Claude Paroz f3c43ad1fd Refs #23919 -- Removed python_2_unicode_compatible decorator usage 2017-01-18 13:44:34 +01:00
Claude Paroz d7b9aaa366 Refs #23919 -- Removed encoding preambles and future imports 2017-01-18 09:55:19 +01:00
Tim Graham b70094f040 Refs #26226 -- Removed support for related manager classes without a _apply_rel_filters() method.
Per deprecation timeline.
2017-01-17 20:52:03 -05:00
François Freitag ee1c1c696b Made prefetch_related SQL inspection tests less brittle.
After refs #16614, integers might appear outside the WHERE clause.
2017-01-09 11:18:32 -05:00
Ramin Farajpour Cami 0a63ef3f61 Fixed #27463 -- Fixed E741 flake8 warnings. 2016-11-14 17:40:28 -05:00
za 321e94fa41 Refs #27392 -- Removed "Tests that", "Ensures that", etc. from test docstrings. 2016-11-10 21:30:21 -05:00
Simon Charette 271bfe65d9
Fixed #26916 -- Fixed prefetch_related when using a cached_property as to_attr.
Thanks Trac alias karyon for the report and Tim for the review.
2016-07-19 16:05:07 -04:00
Simon Charette 53a5fb3cc0 Fixed #26676 -- Prevented prefetching to_attr from caching its result in through attr.
Thanks Ursidours for the report.
2016-05-31 14:32:58 -04:00
Simon Charette 7ec330eeb9 Refs #26565 -- Errored nicely when using Prefetch with a values() queryset.
Thanks Maxime Lorant for the report and Anssi for the suggestion.
2016-05-03 09:28:31 -04:00
Tim Graham 92053acbb9 Fixed E128 flake8 warnings in tests/. 2016-04-08 10:12:33 -04:00
Simon Charette c92123cc1d Fixed #26226 -- Made related managers honor the queryset used for prefetching their results.
Thanks Loïc for the suggested improvements and Tim for the review.
2016-03-02 16:10:18 -05:00
Simon Charette 5d240b070d Refs #17001 -- Added a test for custom prefetch related queryset on generic relations. 2016-03-02 16:08:37 -05:00
Attila Tovt 5e2c4d7afb Fixed #26264 -- Fixed prefetch_related() crashes with values_list(flat=True) 2016-02-26 19:26:15 -05:00
Adam Chainz ef33bc2d4d Fixed #25279 -- Made prefetch_related_objects() public. 2016-02-26 14:55:01 -05:00
Simon Charette c30086159d Used setupTestData in prefetch_related tests. 2016-02-23 13:53:58 -05:00
François Freitag bdbe50a491 Fixed #25546 -- Prevented duplicate queries with nested prefetch_related(). 2016-01-26 07:20:13 -05:00
Ian Foote 86eccdc8b6 Fixed #25544 -- Removed duplicate ids in prefetch_related() queries. 2015-12-17 19:08:30 -05:00
Simon Charette cc8c02fa0f Refs #25693 -- Added a regression test for `to_attr` validation on forward m2m. 2015-11-11 12:25:10 -05:00
Ian Foote 4608573788 Fixed #25693 -- Prevented data loss with Prefetch and ManyToManyField.
Thanks to Jamie Matthews for finding and explaining the bug.
2015-11-10 12:12:07 -05:00
Aymeric Augustin e542e81b39 Renamed descriptor classes for related objects.
The old names were downright confusing. Some seemed to mean the opposite
of what the class actually did.

The new names follow a consistent nomenclature:

    (Forward|Reverse)(ManyToOne|OneToOne|ManyToMany)Descriptor.

I mentioned combinations that do not exist in the docstring in order to
help people who would search for them in the code base.
2015-09-21 22:20:42 +02:00
Dražen Odobašić b1e33ceced Fixed #23395 -- Limited line lengths to 119 characters. 2015-09-12 11:40:50 -04:00
Flavio Curella c2e70f0265 Fixed #21127 -- Started deprecation toward requiring on_delete for ForeignKey/OneToOneField 2015-07-27 18:28:13 -04:00
Gagaro 74261bc593 Fixed #24873 -- Prevented nested Prefetch objects from being overwritten. 2015-06-18 15:42:47 -04:00
Brian King bfb5b7150f Fixed #24912 -- Fixed prefetch_related failure for UUIDField primary keys
This resolves a problem on databases besides PostgreSQL when using
prefetch_related with a source model that uses a UUID primary key.
2015-06-15 09:37:38 -04:00