Opened 16 years ago
Closed 16 years ago
#11662 closed (worksforme)
Filtered Queryset update() on a Proxy Model updates all records
| Reported by: | stryderjzw | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.1 |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Here's my models:
class Item(models.Model):
...
class Bid(models.Model):
...
item = models.ForeignKey(Item)
processed = models.BooleanField(default=False)
...
class Transaction(Bid):
class Meta:
proxy = True
When I run:
Transaction.objects.filter(processed=False, item=2).update(processed=True)
It would set all Transactions.processed to True, when I clearly only want the bids on item 2 to be processed.
I get this SQL:
{'time': '0.000', 'sql': 'UPDATE "game_bid" SET "processed" = true'}
However:
Bid.objects.filter(processed=False, item=2).update(processed=True)
This appears to work as intended.
SQL:
{'time': '0.000', 'sql': 'UPDATE "game_bid" SET "processed" = true WHERE ("game_bid"."item_id" = 6 AND "game_bid"."processed" = false }
Change History (2)
comment:1 by , 16 years ago
| Component: | Uncategorized → Database layer (models, ORM) |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
I cannot reproduce this with r11638 on sqlite.