From 92c49d6f01700961698eb3d79fd393d673cee219 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Tue, 11 Jun 2013 17:54:56 -0400 Subject: [PATCH] Revert "Fixed #20462 - Fixed sqlite regex lookups for null values and non-string fields." This reverts commit 64041f0e6e7a773574d7cde978d16305200004ea. lookup.tests.LookupTests.test_regex_non_string fails under Postgres. We should also try to rewrite the test using an existing model. --- AUTHORS | 1 - django/db/backends/sqlite3/base.py | 2 +- tests/lookup/models.py | 9 --------- tests/lookup/tests.py | 17 +---------------- 4 files changed, 2 insertions(+), 27 deletions(-) diff --git a/AUTHORS b/AUTHORS index 2355eeb655..cedff32fe0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -270,7 +270,6 @@ answer newbie questions, and generally made Django that much better: Brian Harring Brant Harris Ronny Haryanto - Axel Haustant Hawkeye Kent Hauser Joe Heck diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 3808170f9e..a2d925ac3f 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -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)) diff --git a/tests/lookup/models.py b/tests/lookup/models.py index af236cf56f..f388ddf403 100644 --- a/tests/lookup/models.py +++ b/tests/lookup/models.py @@ -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 diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py index 5affac6b00..de7105f92d 100644 --- a/tests/lookup/tests.py +++ b/tests/lookup/tests.py @@ -6,7 +6,7 @@ from operator import attrgetter 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): @@ -610,21 +610,6 @@ class LookupTests(TestCase): self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'b(.).*b\1'), ['', '', '']) - 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$'), - ['']) - def test_nonfield_lookups(self): """ Ensure that a lookup query containing non-fields raises the proper