Fixed #27561 -- Added Oracle support for binary "or" operator.

Removed DatabaseFeatures.supports_bitwise_or feature (unused, always True).
This commit is contained in:
Mariusz Felisiak 2016-12-02 22:59:39 +01:00 committed by Tim Graham
parent 7ed456063b
commit b059ddf066
4 changed files with 2 additions and 4 deletions

View File

@ -57,7 +57,6 @@ class BaseDatabaseFeatures(object):
# Is there a REAL datatype in addition to floats/doubles?
has_real_datatype = False
supports_subqueries_in_group_by = True
supports_bitwise_or = True
# Is there a true datatype for uuid?
has_native_uuid_field = False

View File

@ -14,7 +14,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
supports_subqueries_in_group_by = False
supports_transactions = True
supports_timezones = False
supports_bitwise_or = False
has_native_duration_field = True
can_defer_constraint_checks = True
supports_partially_nullable_unique_constraints = False

View File

@ -442,7 +442,8 @@ WHEN (new.%(col_name)s IS NULL)
elif connector == '&':
return 'BITAND(%s)' % ','.join(sub_expressions)
elif connector == '|':
raise NotImplementedError("Bit-wise or is not supported in Oracle.")
lhs, rhs = sub_expressions
return 'BITAND(-%(lhs)s-1,%(rhs)s)+%(lhs)s' % {'lhs': lhs, 'rhs': rhs}
elif connector == '^':
return 'POWER(%s)' % ','.join(sub_expressions)
return super(DatabaseOperations, self).combine_expression(connector, sub_expressions)

View File

@ -741,7 +741,6 @@ class ExpressionOperatorTests(TestCase):
self.assertEqual(Number.objects.get(pk=self.n.pk).integer, 40)
self.assertEqual(Number.objects.get(pk=self.n.pk).float, Approximate(15.500, places=3))
@skipUnlessDBFeature('supports_bitwise_or')
def test_lefthand_bitwise_or(self):
# LH Bitwise or on integers
Number.objects.filter(pk=self.n.pk).update(integer=F('integer').bitor(48))