mirror of
https://github.com/django/django.git
synced 2025-03-10 09:22:46 +00:00
Removed usage of extra(select) in in forward many-to-many manager prefetch.
This commit is contained in:
parent
c6a4f853c7
commit
ac5e56a47f
@ -76,6 +76,7 @@ from django.db import (
|
|||||||
transaction,
|
transaction,
|
||||||
)
|
)
|
||||||
from django.db.models import Manager, Q, Window, signals
|
from django.db.models import Manager, Q, Window, signals
|
||||||
|
from django.db.models.expressions import RawSQL
|
||||||
from django.db.models.functions import RowNumber
|
from django.db.models.functions import RowNumber
|
||||||
from django.db.models.lookups import GreaterThan, LessThanOrEqual
|
from django.db.models.lookups import GreaterThan, LessThanOrEqual
|
||||||
from django.db.models.query import QuerySet
|
from django.db.models.query import QuerySet
|
||||||
@ -1181,11 +1182,11 @@ def create_forward_many_to_many_manager(superclass, rel, reverse):
|
|||||||
join_table = fk.model._meta.db_table
|
join_table = fk.model._meta.db_table
|
||||||
connection = connections[queryset.db]
|
connection = connections[queryset.db]
|
||||||
qn = connection.ops.quote_name
|
qn = connection.ops.quote_name
|
||||||
queryset = queryset.extra(
|
queryset = queryset.annotate(
|
||||||
select={
|
**{
|
||||||
"_prefetch_related_val_%s"
|
f"_prefetch_related_val_{f.attname}": RawSQL(
|
||||||
% f.attname: "%s.%s"
|
"%s.%s" % (qn(join_table), qn(f.column)), ()
|
||||||
% (qn(join_table), qn(f.column))
|
)
|
||||||
for f in fk.local_related_fields
|
for f in fk.local_related_fields
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user