﻿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
16211	using negated F()-expression in update query	Walter Doekes	David Wobrock	"Hi,

as far as I can tell, there is currently no way to do this with the ORM:
{{{
UPDATE myapp_mymodel SET is_enabled = NOT is_enabled;
}}}
Using this:
{{{
MyModel.objects.update(is_enabled=(not F('is_enabled')))
}}}
.. becomes ""is_enabled = true"". And this:
{{{
MyModel.objects.update(is_enabled=~F('is_enabled'))
}}}
.. doesn't work, because the bitwise not operator is not defined on the `ExpressionNode`.

I've done a patch against 1.2 to fix add that.

It adds a unary ""NOT""-connector to the `combine_expression` in `BaseDatabaseOperations` and it adds the `__invert__` method to the `ExpressionNode`.

If you like this, I'll be happy to do a patch against trunk.

Regards,[[br]]
Walter Doekes[[br]]
OSSO B.V.
"	New feature	closed	Database layer (models, ORM)	dev	Normal	fixed		walter+django@… s.angel@… charette.s@… David Wobrock	Ready for checkin	1	0	0	0	0	0
