Ticket #399: kmt-bigint.diff
File kmt-bigint.diff, 14.2 KB (added by , 15 years ago) |
---|
-
django/db/models/fields/__init__.py
732 732 defaults.update(kwargs) 733 733 return super(IntegerField, self).formfield(**defaults) 734 734 735 class BigIntegerField(IntegerField): 736 empty_strings_allowed = False 737 description = ugettext_lazy("Big (8 byte) integer") 738 MAX_BIGINT = 9223372036854775807 739 def get_internal_type(self): 740 return "BigIntegerField" 741 742 def formfield(self, **kwargs): 743 defaults = {'min_value': -BigIntegerField.MAX_BIGINT - 1, 744 'max_value': BigIntegerField.MAX_BIGINT} 745 defaults.update(kwargs) 746 return super(BigIntegerField, self).formfield(**defaults) 747 735 748 class IPAddressField(Field): 736 749 empty_strings_allowed = False 737 750 description = ugettext_lazy("IP address") -
django/db/backends/postgresql/introspection.py
4 4 # Maps type codes to Django Field types. 5 5 data_types_reverse = { 6 6 16: 'BooleanField', 7 20: 'BigIntegerField', 7 8 21: 'SmallIntegerField', 8 9 23: 'IntegerField', 9 10 25: 'TextField', -
django/db/backends/postgresql/creation.py
18 18 'FilePathField': 'varchar(%(max_length)s)', 19 19 'FloatField': 'double precision', 20 20 'IntegerField': 'integer', 21 'BigIntegerField': 'bigint', 21 22 'IPAddressField': 'inet', 22 23 'NullBooleanField': 'boolean', 23 24 'OneToOneField': 'integer', -
django/db/backends/sqlite3/introspection.py
16 16 'smallinteger': 'SmallIntegerField', 17 17 'int': 'IntegerField', 18 18 'integer': 'IntegerField', 19 'bigint': 'BigIntegerField', 19 20 'integer unsigned': 'PositiveIntegerField', 20 21 'decimal': 'DecimalField', 21 22 'real': 'FloatField', -
django/db/backends/sqlite3/creation.py
19 19 'FilePathField': 'varchar(%(max_length)s)', 20 20 'FloatField': 'real', 21 21 'IntegerField': 'integer', 22 'BigIntegerField': 'bigint', 22 23 'IPAddressField': 'char(15)', 23 24 'NullBooleanField': 'bool', 24 25 'OneToOneField': 'integer', -
django/db/backends/mysql/introspection.py
17 17 FIELD_TYPE.FLOAT: 'FloatField', 18 18 FIELD_TYPE.INT24: 'IntegerField', 19 19 FIELD_TYPE.LONG: 'IntegerField', 20 FIELD_TYPE.LONGLONG: ' IntegerField',20 FIELD_TYPE.LONGLONG: 'BigIntegerField', 21 21 FIELD_TYPE.SHORT: 'IntegerField', 22 22 FIELD_TYPE.STRING: 'CharField', 23 23 FIELD_TYPE.TIMESTAMP: 'DateTimeField', -
django/db/backends/mysql/creation.py
18 18 'FilePathField': 'varchar(%(max_length)s)', 19 19 'FloatField': 'double precision', 20 20 'IntegerField': 'integer', 21 'BigIntegerField': 'bigint', 21 22 'IPAddressField': 'char(15)', 22 23 'NullBooleanField': 'bool', 23 24 'OneToOneField': 'integer', -
django/db/backends/oracle/introspection.py
29 29 def get_field_type(self, data_type, description): 30 30 # If it's a NUMBER with scale == 0, consider it an IntegerField 31 31 if data_type == cx_Oracle.NUMBER and description[5] == 0: 32 return 'IntegerField' 32 if description[4] > 11: 33 return 'BigIntegerField' 34 else: 35 return 'IntegerField' 33 36 else: 34 37 return super(DatabaseIntrospection, self).get_field_type( 35 38 data_type, description) -
django/db/backends/oracle/creation.py
27 27 'FilePathField': 'NVARCHAR2(%(max_length)s)', 28 28 'FloatField': 'DOUBLE PRECISION', 29 29 'IntegerField': 'NUMBER(11)', 30 'BigIntegerField': 'NUMBER(19)', 30 31 'IPAddressField': 'VARCHAR2(15)', 31 32 'NullBooleanField': 'NUMBER(1) CHECK ((%(qn_column)s IN (0,1)) OR (%(qn_column)s IS NULL))', 32 33 'OneToOneField': 'NUMBER(11)', -
django/contrib/admin/options.py
42 42 'form_class': forms.SplitDateTimeField, 43 43 'widget': widgets.AdminSplitDateTime 44 44 }, 45 models.DateField: {'widget': widgets.AdminDateWidget}, 46 models.TimeField: {'widget': widgets.AdminTimeWidget}, 47 models.TextField: {'widget': widgets.AdminTextareaWidget}, 48 models.URLField: {'widget': widgets.AdminURLFieldWidget}, 49 models.IntegerField: {'widget': widgets.AdminIntegerFieldWidget}, 50 models.CharField: {'widget': widgets.AdminTextInputWidget}, 51 models.ImageField: {'widget': widgets.AdminFileWidget}, 52 models.FileField: {'widget': widgets.AdminFileWidget}, 45 models.DateField: {'widget': widgets.AdminDateWidget}, 46 models.TimeField: {'widget': widgets.AdminTimeWidget}, 47 models.TextField: {'widget': widgets.AdminTextareaWidget}, 48 models.URLField: {'widget': widgets.AdminURLFieldWidget}, 49 models.IntegerField: {'widget': widgets.AdminIntegerFieldWidget}, 50 models.BigIntegerField: {'widget': widgets.AdminIntegerFieldWidget}, 51 models.CharField: {'widget': widgets.AdminTextInputWidget}, 52 models.ImageField: {'widget': widgets.AdminFileWidget}, 53 models.FileField: {'widget': widgets.AdminFileWidget}, 53 54 } 54 55 55 56 -
tests/modeltests/model_forms/models.py
13 13 from django.db import models 14 14 from django.core.files.storage import FileSystemStorage 15 15 16 # Python 2.3 doesn't have sorted()17 try:18 sorted19 except NameError:20 from django.utils.itercompat import sorted21 22 16 temp_storage_dir = tempfile.mkdtemp() 23 17 temp_storage = FileSystemStorage(temp_storage_dir) 24 18 … … 201 195 def __unicode__(self): 202 196 return self.name 203 197 198 class BigInt(models.Model): 199 biggie = models.BigIntegerField() 200 201 def __unicode__(self): 202 return unicode(self.biggie) 203 204 204 __test__ = {'API_TESTS': """ 205 205 >>> from django import forms 206 206 >>> from django.forms.models import ModelForm, model_to_dict … … 1145 1145 # Delete the current file since this is not done by Django. 1146 1146 >>> instance.file.delete() 1147 1147 >>> instance.delete() 1148 1149 # BigIntegerField ################################################################ 1150 >>> class BigIntForm(forms.ModelForm): 1151 ... class Meta: 1152 ... model = BigInt 1153 ... 1154 >>> bif = BigIntForm({'biggie': '-9223372036854775808'}) 1155 >>> bif.is_valid() 1156 True 1157 >>> bif = BigIntForm({'biggie': '-9223372036854775809'}) 1158 >>> bif.is_valid() 1159 False 1160 >>> bif.errors 1161 {'biggie': [u'Ensure this value is greater than or equal to -9223372036854775808.']} 1162 >>> bif = BigIntForm({'biggie': '9223372036854775807'}) 1163 >>> bif.is_valid() 1164 True 1165 >>> bif = BigIntForm({'biggie': '9223372036854775808'}) 1166 >>> bif.is_valid() 1167 False 1168 >>> bif.errors 1169 {'biggie': [u'Ensure this value is less than or equal to 9223372036854775807.']} 1148 1170 """} 1149 1171 1150 1172 if test_images: -
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, BigInt 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 BigIntegerFieldTests(django.test.TestCase): 149 def test_limits(self): 150 # Ensure that values that are right at the limits can be saved 151 # and then retrieved without corruption. 152 maxval = 9223372036854775807 153 minval = -maxval - 1 154 BigInt.objects.create(value=maxval) 155 qs = BigInt.objects.filter(value__gte=maxval) 156 self.assertEqual(qs.count(), 1) 157 self.assertEqual(qs[0].value, maxval) 158 BigInt.objects.create(value=minval) 159 qs = BigInt.objects.filter(value__lte=minval) 160 self.assertEqual(qs.count(), 1) 161 self.assertEqual(qs[0].value, minval) 162 163 def test_types(self): 164 b = BigInt(value = 0) 165 self.assertTrue(isinstance(b.value, (int, long))) 166 b.save() 167 self.assertTrue(isinstance(b.value, (int, long))) 168 b = BigInt.objects.all()[0] 169 self.assertTrue(isinstance(b.value, (int, long))) 170 171 def test_coercing(self): 172 BigInt.objects.create(value ='10') 173 b = BigInt.objects.get(value = '10') 174 self.assertEqual(b.value, 10) 175 -
tests/regressiontests/model_fields/models.py
51 51 class BigS(models.Model): 52 52 s = models.SlugField(max_length=255) 53 53 54 class BigInt(models.Model): 55 value = models.BigIntegerField() 56 null_value = models.BigIntegerField(null = True, blank = True) 54 57 55 58 ############################################################################### 56 59 # ImageField -
tests/regressiontests/introspection/tests.py
77 77 cursor = connection.cursor() 78 78 desc = connection.introspection.get_table_description(cursor, Reporter._meta.db_table) 79 79 self.assertEqual([datatype(r[1], r) for r in desc], 80 ['IntegerField', 'CharField', 'CharField', 'CharField' ])80 ['IntegerField', 'CharField', 'CharField', 'CharField', 'BigIntegerField']) 81 81 82 82 # Regression test for #9991 - 'real' types in postgres 83 83 if settings.DATABASE_ENGINE.startswith('postgresql'): -
tests/regressiontests/introspection/models.py
4 4 first_name = models.CharField(max_length=30) 5 5 last_name = models.CharField(max_length=30) 6 6 email = models.EmailField() 7 facebook_user_id = models.BigIntegerField() 7 8 8 9 def __unicode__(self): 9 10 return u"%s %s" % (self.first_name, self.last_name) -
docs/topics/forms/modelforms.txt
46 46 =============================== ======================================== 47 47 ``AutoField`` Not represented in the form 48 48 49 ``BigIntegerField`` ``IntegerField`` with ``min_value`` set 50 to -9223372036854775808 and ``max_value`` 51 set to 9223372036854775807. 52 49 53 ``BooleanField`` ``BooleanField`` 50 54 51 55 ``CharField`` ``CharField`` with ``max_length`` set to … … 108 112 The ``FloatField`` form field and ``DecimalField`` model and form fields 109 113 are new in Django 1.0. 110 114 115 .. versionadded:: 1.2 116 The ``BigIntegerField`` is new in Django 1.2. 117 118 111 119 As you might expect, the ``ForeignKey`` and ``ManyToManyField`` model field 112 120 types are special cases: 113 121 -
docs/ref/models/fields.txt
299 299 primary key field will automatically be added to your model if you don't specify 300 300 otherwise. See :ref:`automatic-primary-key-fields`. 301 301 302 ``BigIntegerField`` 303 ------------------- 304 305 .. versionadded:: 1.2 306 307 .. class:: BigIntegerField([**options]) 308 309 A 64 bit integer, much like an :class:`IntegerField` except that it is 310 guaranteed to fit numbers from -9223372036854775808 to 9223372036854775807. The 311 admin represents this as an ``<input type="text">`` (a single-line input). 312 313 302 314 ``BooleanField`` 303 315 ---------------- 304 316