Hi,

I found myself with a use-case today of wanting to return some data from an
update, as I want to make sure I return exactly what is in the database
without making an extra query.

I've found https://code.djangoproject.com/ticket/28682 and agree with the
resolution there.

I suppose there is a way to do this in a backwards compatible way,
something like:

Foo.objects.update(["id", "name"], name="Rob")

But it's very ugly. But how about a new method:

Foo.objects.update_returning(["id", "name"], name="Rob")

Doesn't seem quite so bad. There's also a possibility of something like:

Foo.objects.update_returning(updates={"name": "Rob"}, returning=["id",
"name"])

I'd expect it to return a list of dicts. I'm not sure what's best, if
anything. It could be it's a bit too niche, but it is sometimes quite
useful.

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAHoz%3DMaDz7VLXqRk01D_bUOLN%3D5TBiqVrw-BzyLogeaTMtXM4g%40mail.gmail.com.

Reply via email to