diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2010-01-09 22:05:10 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2010-01-09 22:05:10 +0000 |
| commit | 18723e6e24a08579082ed308e417bc1cc52aa407 (patch) | |
| tree | 5ce9af79d04f5bad14a8d4d61520673a6b76e027 /tests/regressiontests/model_fields/tests.py | |
| parent | 1d61a1eb2a21b550e8e4e63fbb27cbe05ed2aa00 (diff) | |
Fixed #10015 -- PostgreSQL 8.3+ no longer barfs when passing an integer as a filter() value for a CharField or TextField. Thanks, carljm
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12150 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/model_fields/tests.py')
| -rw-r--r-- | tests/regressiontests/model_fields/tests.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py index ea7b49ab7e..dd4e7462bf 100644 --- a/tests/regressiontests/model_fields/tests.py +++ b/tests/regressiontests/model_fields/tests.py @@ -6,7 +6,7 @@ from django import forms from django.db import models from django.core.exceptions import ValidationError -from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt +from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post try: from decimal import Decimal @@ -227,3 +227,16 @@ class BigIntegerFieldTests(django.test.TestCase): b = BigInt.objects.get(value = '10') self.assertEqual(b.value, 10) +class TypeCoercionTests(django.test.TestCase): + """ + Test that database lookups can accept the wrong types and convert + them with no error: especially on Postgres 8.3+ which does not do + automatic casting at the DB level. See #10015. + + """ + def test_lookup_integer_in_charfield(self): + self.assertEquals(Post.objects.filter(title=9).count(), 0) + + def test_lookup_integer_in_textfield(self): + self.assertEquals(Post.objects.filter(body=24).count(), 0) + |
