Changes between Version 1 and Version 2 of Ticket #36157, comment 3


Ignore:
Timestamp:
Jan 29, 2025, 5:25:31 PM (24 hours ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #36157, comment 3

    v1 v2  
    77The 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`?
    88
    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`) call if it relies on prefetching.
     9Adapting `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.
    1010
    1111If 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.
Back to Top