Opened 7 years ago
Closed 7 years ago
#28820 closed Bug (fixed)
update() produces extra query with proxy model
Reported by: | Yan Mitrofanov | Owned by: | Yan Mitrofanov |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Assume we have these models:
class Chef(models.Model): name = models.CharField(max_length=50) class Meta: db_table = "chef" class ProxyChef(Chef): class Meta: proxy = True
If we execute update query on proxy
ProxyChef.objects.filter(id=1).update(name='William')
We get two queries
SELECT "chef"."id" FROM "chef" WHERE "chef"."id" = 1 UPDATE "chef" SET "name" = 'William' WHERE "chef"."id" IN (1)
The first one is totally unnecessary.
Change History (3)
comment:1 by , 7 years ago
Owner: | changed from | to
---|
comment:2 by , 7 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Note:
See TracTickets
for help on using tickets.
PR