mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #25912 -- Added binary left/right shift operators to F expressions.
Thanks Mariusz Felisiak for review and MySQL advice.
This commit is contained in:
parent
f0ef0c49e9
commit
1c12df4aa6
7 changed files with 37 additions and 5 deletions
|
@ -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
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -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
|
||||
--------------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue