#34227: multi level FilteredRelation with select_related may set wrong related
object
-------------------------------+--------------------------------------
Reporter: zhu | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Comment (by zhu):
Seems this bug can be fixed by:
{{{
M django/db/models/sql/compiler.py
@@ -1270,6 +1270,9 @@ class SQLCompiler:
if from_obj:
final_field.remote_field.set_cached_value(from_obj,
obj)
+ def no_local_setter(obj, from_obj):
+ pass
+
def remote_setter(name, obj, from_obj):
setattr(from_obj, name, obj)
@@ -1291,7 +1294,7 @@ class SQLCompiler:
"model": model,
"field": final_field,
"reverse": True,
- "local_setter": partial(local_setter,
final_field),
+ "local_setter": partial(local_setter,
final_field) if len(joins) <= 2 else no_local_setter,
"remote_setter": partial(remote_setter, name),
"from_parent": from_parent,
}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34227#comment:1>
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/010701854c55899c-acab3c53-8e2b-4183-8543-5e2b0db58530-000000%40eu-central-1.amazonses.com.