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',
|
||||
'contains': 'LIKE BINARY %s',
|
||||
'icontains': 'LIKE %s',
|
||||
'regex': 'REGEXP BINARY %s',
|
||||
'iregex': 'REGEXP %s',
|
||||
'gt': '> %s',
|
||||
'gte': '>= %s',
|
||||
'lt': '< %s',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -14,3 +14,5 @@ Bugfixes
|
|||
|
||||
* Fixed admin check crash when using a query expression in
|
||||
``ModelAdmin.ordering`` (:ticket:`29428`).
|
||||
|
||||
* Fixed ``__regex`` and ``__iregex`` lookups with MySQL 8 (:ticket:`29451`).
|
||||
|
|
Loading…
Reference in New Issue