mirror of https://github.com/django/django.git
Refs #29451 -- Fixed regex/iregex lookups on MySQL 8.
This commit is contained in:
parent
b0fbfae093
commit
4249076844
|
@ -141,8 +141,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||||
'iexact': 'LIKE %s',
|
'iexact': 'LIKE %s',
|
||||||
'contains': 'LIKE BINARY %s',
|
'contains': 'LIKE BINARY %s',
|
||||||
'icontains': 'LIKE %s',
|
'icontains': 'LIKE %s',
|
||||||
'regex': 'REGEXP BINARY %s',
|
|
||||||
'iregex': 'REGEXP %s',
|
|
||||||
'gt': '> %s',
|
'gt': '> %s',
|
||||||
'gte': '>= %s',
|
'gte': '>= %s',
|
||||||
'lt': '< %s',
|
'lt': '< %s',
|
||||||
|
|
|
@ -282,3 +282,14 @@ class DatabaseOperations(BaseDatabaseOperations):
|
||||||
# EXTENDED and FORMAT are mutually exclusive options.
|
# EXTENDED and FORMAT are mutually exclusive options.
|
||||||
prefix += ' EXTENDED'
|
prefix += ' EXTENDED'
|
||||||
return prefix
|
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
|
||||||
|
|
|
@ -14,3 +14,5 @@ Bugfixes
|
||||||
|
|
||||||
* Fixed admin check crash when using a query expression in
|
* Fixed admin check crash when using a query expression in
|
||||||
``ModelAdmin.ordering`` (:ticket:`29428`).
|
``ModelAdmin.ordering`` (:ticket:`29428`).
|
||||||
|
|
||||||
|
* Fixed ``__regex`` and ``__iregex`` lookups with MySQL 8 (:ticket:`29451`).
|
||||||
|
|
Loading…
Reference in New Issue