diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py
index fecd393..f075fa3 100644
a
|
b
|
class Combinable(object):
|
32 | 32 | # usage. |
33 | 33 | BITAND = '&' |
34 | 34 | BITOR = '|' |
| 35 | BITLEFTSHIFT = '<<' |
| 36 | BITRIGHTSHIFT = '>>' |
35 | 37 | |
36 | 38 | def _combine(self, other, connector, reversed, node=None): |
37 | 39 | if not hasattr(other, 'resolve_expression'): |
… |
… |
class Combinable(object):
|
78 | 80 | def bitand(self, other): |
79 | 81 | return self._combine(other, self.BITAND, False) |
80 | 82 | |
| 83 | def bitleftshift(self, other): |
| 84 | return self._combine(other, self.BITLEFTSHIFT, False) |
| 85 | |
| 86 | def bitrightshift(self, other): |
| 87 | return self._combine(other, self.BITRIGHTSHIFT, False) |
| 88 | |
81 | 89 | def __or__(self, other): |
82 | 90 | raise NotImplementedError( |
83 | 91 | "Use .bitand() and .bitor() for bitwise logical operations." |
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
index f688927..9a1d930 100644
a
|
b
|
class ExpressionOperatorTests(TestCase):
|
604 | 604 | self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 40) |
605 | 605 | self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(15.500, places=3)) |
606 | 606 | |
| 607 | def test_lefthand_bitwise_binary_left_shift_operator(self): |
| 608 | Number.objects.filter(pk=self.n.pk).update(integer=F('integer').bitleftshift(2)) |
| 609 | self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 168) |
| 610 | |
| 611 | def test_lefthand_bitwise_binary_right_shift_operator(self): |
| 612 | Number.objects.filter(pk=self.n.pk).update(integer=F('integer').bitrightshift(2)) |
| 613 | self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 10) |
| 614 | |
607 | 615 | @skipUnlessDBFeature('supports_bitwise_or') |
608 | 616 | def test_lefthand_bitwise_or(self): |
609 | 617 | # LH Bitwise or on integers |