Changes between Version 1 and Version 2 of Ticket #36157, comment 3
- Timestamp:
- Jan 29, 2025, 5:25:31 PM (24 hours ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #36157, comment 3
v1 v2 7 7 The thing is prefetching **must** have `blog_id` otherwise it has no way to build the associative map between `Blog` instances and `Post` to populate `blog.posts.all()`. In other words if I gave you a list of the form `posts = [{"id": 1, "name": "Some blog Post"}, {"id": 2, "name": "Some other blog Post"}` how would you partition it by `blog_id`? 8 8 9 Adapting `prefetch_related` to error out if provided an inadequate `Prefetch(queryset)` could potentially be done but that would not solve your actual problem.The third-party library you are using to automatically generate these queries is flawed and should include `blog_id` in the select mask (AKA the `only`) callif it relies on prefetching.9 Adapting `prefetch_related` to error out if provided an inadequate `Prefetch(queryset)` could potentially be done but that would not solve your actual problem.The third-party library you are using to automatically generate these queries is flawed and should include `blog_id` in the the `only` calls it issues if it relies on prefetching. 10 10 11 11 If you'd like to catch these early I'd suggest looking at the potential solution to have warnings emitted on query leaks in ticket:33835#comment:2.