#36117: Composite primary key in Case statement evades right-hand side sanity
checking
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
Without implementing the full thing it seems that simply removing the
`Case.resolve_expression` implementation (which is basically equivalent to
`BaseExpression.resolve_expression`) passes the tests
{{{#!diff
diff --git a/django/db/models/expressions.py
b/django/db/models/expressions.py
index 2494ec4139..83ace22086 100644
--- a/django/db/models/expressions.py
+++ b/django/db/models/expressions.py
@@ -1686,20 +1686,6 @@ def get_source_expressions(self):
def set_source_expressions(self, exprs):
*self.cases, self.default = exprs
- def resolve_expression(
- self, query=None, allow_joins=True, reuse=None, summarize=False,
for_save=False
- ):
- c = self.copy()
- c.is_summary = summarize
- for pos, case in enumerate(c.cases):
- c.cases[pos] = case.resolve_expression(
- query, allow_joins, reuse, summarize, for_save
- )
- c.default = c.default.resolve_expression(
- query, allow_joins, reuse, summarize, for_save
- )
- return c
-
def copy(self):
c = super().copy()
c.cases = c.cases[:]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36117#comment:2>
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 visit
https://groups.google.com/d/msgid/django-updates/01070194823afdde-bf3acc4d-a3ef-4c88-a446-0b106bc6a49a-000000%40eu-central-1.amazonses.com.