update() on a sliced query set updates all objects.
|Reported by:||sebastian_noack||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||russellm, mtredinnick||Triage Stage:||Unreviewed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
What do think following code will do?
No it won't update the first object in the model, it will update all objects. Although I expected that it updates the first object, we should just prevent the user from doing this. Because of (at least MySql) do not support offset for UPDATE. It supports limit but their might be DBMS which do not support both on UPDATE and if you think about this use case, it is a real corner case. But anyway the user should not destroy his data by accident. I have written a patch which adds the same sanity check to QuerySet.update() as already done when calling QuerySet.order_by().
Change History (7)
Changed 8 years ago by sebastian_noack
comment:1 Changed 7 years ago by gav
- Keywords qsrf-cleanup added
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset