1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

[1.1.X] Fixed #10015 -- PostgreSQL 8.3+ no longer barfs when passing an integer as a filter() value for a CharField? or TextField?. Thanks, carljm

Backport of r12150 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12263 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Karen Tracey
2010-01-19 16:55:22 +00:00
parent a8e659c54f
commit 46d8ae7c24
3 changed files with 27 additions and 1 deletions

View File

@@ -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
from models import Foo, Bar, Whiz, BigD, BigS, Image, Post
try:
from decimal import Decimal
@@ -144,3 +144,17 @@ class SlugFieldTests(django.test.TestCase):
bs = BigS.objects.create(s = 'slug'*50)
bs = BigS.objects.get(pk=bs.pk)
self.assertEqual(bs.s, 'slug'*50)
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)