Calling update() on EmptyQuerySet updates all rows in database
|Reported by:||jensadne||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.1|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Assuming a model Foo, with a CharField "bar" of which there is for instance 42 stored instances in the database.
Foo.objects.none().count() returns the expected result 0.
However, Foo.objects.none().update(bar='baz') returns 42, and all 42 rows in the database have been updated.
This seems to be caused by EmptyQuerySet not overriding update(), this method should be overridden to just return 0.
Change History (8)
Changed 6 years ago by jensadne
comment:1 Changed 6 years ago by Alex
- Needs documentation unset
- Needs tests set
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
Changed 6 years ago by cwebber
comment:4 Changed 6 years ago by Alex
- Needs tests unset
- Triage Stage changed from Accepted to Ready for checkin