Comment (by zhu):
Replying to [comment:6 Mariusz Felisiak]:
> Thanks! Would you like to prepare a patch?
{{{
diff --git a/django/db/models/sql/compiler.py
b/django/db/models/sql/compiler.py
index 2b66ab12b4..831ef79269 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -1261,7 +1261,7 @@ class SQLCompiler:
)
get_related_klass_infos(klass_info, next_klass_infos)
- def local_setter(obj, from_obj):
+ def local_setter(f, obj, from_obj):
# Set a reverse fk object when relation is non-empty.
if from_obj:
f.remote_field.set_cached_value(from_obj, obj)
@@ -1287,7 +1287,7 @@ class SQLCompiler:
"model": model,
"field": f,
"reverse": True,
- "local_setter": local_setter,
+ "local_setter": partial(local_setter, f),
"remote_setter": partial(remote_setter, name),
"from_parent": from_parent,
}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34226#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Mariusz Felisiak):
Thanks, can you prepare PR (with patch and tests) and
[https://docs.djangoproject.com/en/stable/intro/contributing/#committing-
the-changes-in-the-patch submit it via GitHub]? (docs changes are not
required.)
--
Ticket URL: <https://code.djangoproject.com/ticket/34226#comment:8>
Comment (by zhu):
Replying to [comment:8 Mariusz Felisiak]:
> Thanks, can you prepare PR (with patch and tests) and
[https://docs.djangoproject.com/en/stable/intro/contributing/#committing-
the-changes-in-the-patch submit it via GitHub]? (docs changes are not
required.)
https://github.com/django/django/pull/16398 done.
--
Ticket URL: <https://code.djangoproject.com/ticket/34226#comment:9>
* owner: nobody => zhu
* status: new => assigned
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/34226#comment:10>
Comment (by GitHub <noreply@…>):
In [changeset:"e07e83589b05e030d1bc0015a758bf3abc4da7cc" e07e8358]:
{{{
#!CommitTicketReference repository=""
revision="e07e83589b05e030d1bc0015a758bf3abc4da7cc"
Refs #34226 -- Renamed local field variables in
SQLCompiler.get_related_selections() to avoid redefinition.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34226#comment:11>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/34226#comment:12>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"bbeeb45161da251bb7297b60d6155e7b4efdbc9f" bbeeb45]:
{{{
#!CommitTicketReference repository=""
revision="bbeeb45161da251bb7297b60d6155e7b4efdbc9f"
Fixed #34226 -- Fixed QuerySet.select_related() with multiple
FilteredRelations to the OneToOneField.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34226#comment:13>