#34178: Prefetching a foreign key on GenericForeignKey results in incorrect
queryset being selected
-------------------------------------+-------------------------------------
Reporter: Rohan Nahata | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution: duplicate
Keywords: GenericForeignKey, | Triage Stage:
prefetch_related | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):
* status: new => closed
* has_patch: 1 => 0
* resolution: => duplicate
Comment:
Replying to [comment:5 MahavirAce]:
> We communicated with the author of #33651. He told us he was looking to
build a new functionality. Using his functionality, a developer will use
Prefetch functionality with GenericForeignkey. The ticket that @rohanahata
raised was -->we got the wrong data when we fired query as mentioned in
our ticket . We want to solve that bug . So our ticket is not a duplicate
of #33651. I request you to please reopen our ticket on these grounds. We
also have a patch for the same
#33651 is about exactly the same use case (see
[https://code.djangoproject.com/ticket/33651#comment:1 comment]) so using
`prefetch_related()` to `GenericForeignkey` with different content types.
We believe that a proper implementation here is to add the
`GenericPrefetch()` subclass. As I mentioned, the current behavior is
documented so we're treating this as a new feature.
> We also have a patch for the same .
You can submit the alternative patch to the #33651, if you believe that
`GenericPrefetch` is unnecessary and there is a better approach.
--
Ticket URL: <https://code.djangoproject.com/ticket/34178#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070184bc892d2b-9f7abde7-36d9-40bd-97ab-4f6798c1d5e9-000000%40eu-central-1.amazonses.com.