summaryrefslogtreecommitdiff
path: root/django/db/backends/mysql/operations.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/backends/mysql/operations.py')
-rw-r--r--django/db/backends/mysql/operations.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py
index e5c0c5c71b..47e179db41 100644
--- a/django/db/backends/mysql/operations.py
+++ b/django/db/backends/mysql/operations.py
@@ -282,3 +282,14 @@ class DatabaseOperations(BaseDatabaseOperations):
# EXTENDED and FORMAT are mutually exclusive options.
prefix += ' EXTENDED'
return prefix
+
+ def regex_lookup(self, lookup_type):
+ # REGEXP BINARY doesn't work correctly in MySQL 8+ and REGEXP_LIKE
+ # doesn't exist in MySQL 5.6.
+ if self.connection.mysql_version < (8, 0, 0):
+ if lookup_type == 'regex':
+ return '%s REGEXP BINARY %s'
+ return '%s REGEXP %s'
+
+ match_option = 'c' if lookup_type == 'regex' else 'i'
+ return "REGEXP_LIKE(%%s, %%s, '%s')" % match_option