Skip to content

Commit

Permalink
Revert "Fixed #20462 - Fixed sqlite regex lookups for null values and…
Browse files Browse the repository at this point in the history
… non-string fields."

This reverts commit 64041f0.

lookup.tests.LookupTests.test_regex_non_string fails under Postgres.
We should also try to rewrite the test using an existing model.
  • Loading branch information
timgraham committed Jun 11, 2013
1 parent 78974ed commit 92c49d6
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 27 deletions.
1 change: 0 additions & 1 deletion AUTHORS
Expand Up @@ -270,7 +270,6 @@ answer newbie questions, and generally made Django that much better:
Brian Harring <ferringb@gmail.com>
Brant Harris
Ronny Haryanto <http://ronny.haryan.to/>
Axel Haustant <noirbizarre@gmail.com>
Hawkeye
Kent Hauser <kent@khauser.net>
Joe Heck <http://www.rhonabwy.com/wp/>
Expand Down
2 changes: 1 addition & 1 deletion django/db/backends/sqlite3/base.py
Expand Up @@ -519,4 +519,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, re_string))
9 changes: 0 additions & 9 deletions tests/lookup/models.py
Expand Up @@ -57,12 +57,3 @@ class Player(models.Model):

def __str__(self):
return self.name


@python_2_unicode_compatible
class RegexTestModel(models.Model):
name = models.CharField(max_length=100, null=True)
integer = models.IntegerField(null=True)

def __str__(self):
return self.name
17 changes: 1 addition & 16 deletions tests/lookup/tests.py
Expand Up @@ -6,7 +6,7 @@
from django.core.exceptions import FieldError
from django.test import TestCase, skipUnlessDBFeature

from .models import Author, Article, Tag, Game, Season, Player, RegexTestModel
from .models import Author, Article, Tag, Game, Season, Player


class LookupTests(TestCase):
Expand Down Expand Up @@ -610,21 +610,6 @@ def test_regex_backreferencing(self):
self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'b(.).*b\1'),
['<Article: barfoobaz>', '<Article: bazbaRFOO>', '<Article: foobarbaz>'])

def test_regex_null(self):
"""
Ensure that a regex lookup does not fail on null/None values
"""
RegexTestModel.objects.create(name=None)
self.assertQuerysetEqual(RegexTestModel.objects.filter(name__regex=r'^$'), [])

def test_regex_non_string(self):
"""
Ensure that a regex lookup does not fail on non-string fields
"""
RegexTestModel.objects.create(name='test', integer=5)
self.assertQuerysetEqual(RegexTestModel.objects.filter(integer__regex=r'^5$'),
['<RegexTestModel: test>'])

def test_nonfield_lookups(self):
"""
Ensure that a lookup query containing non-fields raises the proper
Expand Down

0 comments on commit 92c49d6

Please sign in to comment.