Ticket #10015: 10015_11X.diff
File 10015_11X.diff, 2.6 KB (added by , 15 years ago) |
---|
-
django/db/models/fields/__init__.py
435 435 ugettext_lazy("This field cannot be null.")) 436 436 return smart_unicode(value) 437 437 438 def get_db_prep_value(self, value): 439 return self.to_python(value) 440 438 441 def formfield(self, **kwargs): 439 442 defaults = {'max_length': self.max_length} 440 443 defaults.update(kwargs) … … 833 836 def get_internal_type(self): 834 837 return "TextField" 835 838 839 def get_db_prep_value(self, value): 840 if isinstance(value, basestring) or value is None: 841 return value 842 return smart_unicode(value) 843 836 844 def formfield(self, **kwargs): 837 845 defaults = {'widget': forms.Textarea} 838 846 defaults.update(kwargs) -
tests/regressiontests/model_fields/tests.py
6 6 from django.db import models 7 7 from django.core.exceptions import ValidationError 8 8 9 from models import Foo, Bar, Whiz, BigD, BigS, Image 9 from models import Foo, Bar, Whiz, BigD, BigS, Image, Post 10 10 11 11 try: 12 12 from decimal import Decimal … … 144 144 bs = BigS.objects.create(s = 'slug'*50) 145 145 bs = BigS.objects.get(pk=bs.pk) 146 146 self.assertEqual(bs.s, 'slug'*50) 147 148 class TypeCoercionTests(django.test.TestCase): 149 """ 150 Test that database lookups can accept the wrong types and convert 151 them with no error: especially on Postgres 8.3+ which does not do 152 automatic casting at the DB level. See #10015. 153 154 """ 155 def test_lookup_integer_in_charfield(self): 156 self.assertEquals(Post.objects.filter(title=9).count(), 0) 157 158 def test_lookup_integer_in_textfield(self): 159 self.assertEquals(Post.objects.filter(body=24).count(), 0) 160 -
tests/regressiontests/model_fields/models.py
52 52 s = models.SlugField(max_length=255) 53 53 54 54 55 class Post(models.Model): 56 title = models.CharField(max_length=100) 57 body = models.TextField() 58 55 59 ############################################################################### 56 60 # ImageField 57 61