Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #20462 - Replaced the str() cast introduced in 273dc55 by force…

…_text()
  • Loading branch information...
commit a9ea7d8c708c8265cccc17f23c62b2268d9e94f8 1 parent 273dc55
Loïc Bistuer loic authored
Showing with 9 additions and 1 deletion.
  1. +2 −1  django/db/backends/sqlite3/base.py
  2. +7 −0 tests/lookup/tests.py
3  django/db/backends/sqlite3/base.py
View
@@ -19,6 +19,7 @@
from django.db.models import fields
from django.db.models.sql import aggregates
from django.utils.dateparse import parse_date, parse_datetime, parse_time
+from django.utils.encoding import force_text
from django.utils.functional import cached_property
from django.utils.safestring import SafeBytes
from django.utils import six
@@ -522,4 +523,4 @@ def _sqlite_format_dtdelta(dt, conn, days, secs, usecs):
return str(dt)
def _sqlite_regexp(re_pattern, re_string):
- return bool(re.search(re_pattern, str(re_string))) if re_string is not None else False
+ return bool(re.search(re_pattern, force_text(re_string))) if re_string is not None else False
7 tests/lookup/tests.py
View
@@ -625,6 +625,13 @@ def test_regex_non_string(self):
self.assertQuerysetEqual(Season.objects.filter(gt__regex=r'^444$'),
['<Season: 2013>'])
+ def test_regex_non_ascii(self):
+ """
+ Ensure that a regex lookup does not trip on non-ascii characters.
+ """
+ Player.objects.create(name='\u2660')
+ Player.objects.get(name__regex='\u2660')
+
def test_nonfield_lookups(self):
"""
Ensure that a lookup query containing non-fields raises the proper
Please sign in to comment.
Something went wrong with that request. Please try again.