﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
7210	Added expression support for QuerySet.update	Sebastian Noack	nobody	"I think QuerySet.update works to inflexible. In SQL you can define expressions containing the current value or the value of an other column in the update clause, for Example to incrementing a value in the result set. This is not possible by the ORM at the moment. I wrote a possible patch, with which you can do following:
[[BR]][[BR]]
{{{
from django.db.models.sql.expressions import *

# Equivalent to model.all().update(foo=42)
model.all().update(foo=LiteralExpr(42))
# Increment column 'foo' by one.
model.all().update(foo=CurrentExpr() + LiteralExpr(1))
# Swap the value of the column 'foo' and 'bar'.
model.all().update(foo=ColumnExpr('bar'), bar=ColumnExpr('foo'))
}}}
"		closed	Database layer (models, ORM)	dev		fixed		Russell Keith-Magee Malcolm Tredinnick Nicolas Lara gav@… Gonzalo Saavedra Joel Watts simon@… Reflejo@…	Accepted	1	1	1	1	0	0
