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

@ -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."