Fixed #25912 -- Added binary left/right shift operators to F expressions.

Thanks Mariusz Felisiak for review and MySQL advice.
This commit is contained in:
anabelensc 2015-12-14 19:13:21 +00:00 committed by Tim Graham
parent f0ef0c49e9
commit 1c12df4aa6
7 changed files with 37 additions and 5 deletions

View file

@ -367,6 +367,9 @@ Models
:meth:`~django.db.models.Expression.desc` to control
the ordering of null values.
* The new ``F`` expression ``bitleftshift()`` and ``bitrightshift()`` methods
allow :ref:`bitwise shift operations <using-f-expressions-in-filters>`.
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~

View file

@ -652,11 +652,15 @@ that were modified more than 3 days after they were published::
>>> from datetime import timedelta
>>> Entry.objects.filter(mod_date__gt=F('pub_date') + timedelta(days=3))
The ``F()`` objects support bitwise operations by ``.bitand()`` and
``.bitor()``, for example::
The ``F()`` objects support bitwise operations by ``.bitand()``, ``.bitor()``,
``.bitrightshift()``, and ``.bitleftshift()``. For example::
>>> F('somefield').bitand(16)
.. versionchanged:: 1.11
Support for ``.bitrightshift()`` and ``.bitleftshift()`` was added.
The ``pk`` lookup shortcut
--------------------------