#19102 closed Bug (fixed)
Deletion using subqueries doesn't work for aggregates, extra or select_related
| Reported by: | Anssi Kääriäinen | Owned by: | Anssi Kääriäinen |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Release blocker | Keywords: | |
| Cc: | django@… | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Aggregates, extra and select_related add columns to the subselect. However, the subselect must contain only one column.
Example case (modified from #18676's example):
class OrgUnit(models.Model):
name = models.CharField(max_length=64, unique=True)
class Login(models.Model):
description = models.CharField(max_length=32)
orgunit = models.ForeignKey(OrgUnit)
Login.objects.extra(
select={'foo':'description'}
).annotate(
n=models.Count('description')
).filter(n=1).select_related('orgunit').delete()
The above fails with "too many columns in subquery" for various databases.
I have a work-in-progress patch for this at: https://github.com/akaariai/django/commit/34a39ba8981638db2eb3fdb3d8d45393130a9d99
This is a regression caused by #18676, so marking as release blocker.
Change History (6)
comment:1 by , 13 years ago
| Cc: | added |
|---|
comment:2 by , 13 years ago
| Owner: | changed from to |
|---|
comment:3 by , 13 years ago
| Patch needs improvement: | unset |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
comment:4 by , 13 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Updated patch at https://github.com/akaariai/django/compare/ticket_18676_fix