#15566: .update queries should affect Date*Field's with auto_now -------------------------------------+------------------------------------- Reporter: jdunck | Owner: bberes Type: Bug | Status: assigned Component: Database layer | Version: 1.2 (models, ORM) | Resolution: Severity: Normal | Triage Stage: Accepted Keywords: | Needs documentation: 0 Has patch: 0 | Patch needs improvement: 0 Needs tests: 0 | UI/UX: 0 Easy pickings: 1 | -------------------------------------+-------------------------------------
Comment (by lukeplant): I disagree with Carl on this one. I have always interpreted `QuerySet.update()` as a lower-level SQL construct, and would be pretty surprised if it did anything other than update the fields that I explicitly told it to. I think the documentation is ambiguous - it simply doesn't state how `QuerySet.update()` and `auto_now` interact. I had interpreted it the other way to you - that `update()` does a SQL update of exactly the fields you specify, and nothing more. I think either interpretation is valid, and it is up to us to decide how to change the behaviour or clarify the docs. I can think of ways the proposed change could break people's code. If I had an auto_now field that was used to essentially track the last modified timestamp of 'public' data in table, and then added some 'internal' state data to a table, I might make use of the current behaviour of `QuerySet.update()` to avoid triggering the `auto_now` behaviour (or anything else that might normally run on model `save()`). In fact I have coded some models where I have a split just like this. I can't remember if they had `auto_now` fields, but I wouldn't have wanted them to be updated when the internal fields were changed. In addition, with the proposed change it's hard to see how you **would** execute a SQL "update-these-fields-and-only-these-fields-and-don't-do anything-special" command. I had relied on `QuerySet.update()` for that until now. It's not hard to add a field to the update call, it's harder to remove one. -- Ticket URL: <https://code.djangoproject.com/ticket/15566#comment:12> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.