summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-01-03 07:13:12 +0100
committerTim Graham <timograham@gmail.com>2017-01-03 12:41:44 -0500
commitfd2f7e47671239dcff98cfb922221ab170aa6461 (patch)
tree51ffcbfb2fd6f49fb5c902e9070744a3a48be343 /django
parent27267afc4137142e4f0b36c83cec861ee6924186 (diff)
Fixed #27681 -- Fixed binary &/| operators for negative values on MySQL.
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/mysql/operations.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py
index dd9f56e88d..a9c39b5363 100644
--- a/django/db/backends/mysql/operations.py
+++ b/django/db/backends/mysql/operations.py
@@ -199,11 +199,12 @@ class DatabaseOperations(BaseDatabaseOperations):
return "VALUES " + values_sql
def combine_expression(self, connector, sub_expressions):
- """
- MySQL requires special cases for ^ operators in query expressions
- """
if connector == '^':
return 'POW(%s)' % ','.join(sub_expressions)
+ # Convert the result to a signed integer since MySQL's binary operators
+ # return an unsigned integer.
+ elif connector in ('&', '|'):
+ return 'CONVERT(%s, SIGNED)' % connector.join(sub_expressions)
return super(DatabaseOperations, self).combine_expression(connector, sub_expressions)
def get_db_converters(self, expression):