mirror of
https://github.com/django/django.git
synced 2025-09-02 08:47:34 +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
|
@ -30,6 +30,8 @@ class Combinable(object):
|
|||
# usage.
|
||||
BITAND = '&'
|
||||
BITOR = '|'
|
||||
BITLEFTSHIFT = '<<'
|
||||
BITRIGHTSHIFT = '>>'
|
||||
|
||||
def _combine(self, other, connector, reversed, node=None):
|
||||
if not hasattr(other, 'resolve_expression'):
|
||||
|
@ -76,6 +78,12 @@ class Combinable(object):
|
|||
def bitand(self, other):
|
||||
return self._combine(other, self.BITAND, False)
|
||||
|
||||
def bitleftshift(self, other):
|
||||
return self._combine(other, self.BITLEFTSHIFT, False)
|
||||
|
||||
def bitrightshift(self, other):
|
||||
return self._combine(other, self.BITRIGHTSHIFT, False)
|
||||
|
||||
def __or__(self, other):
|
||||
raise NotImplementedError(
|
||||
"Use .bitand() and .bitor() for bitwise logical operations."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue