Ticket #399: bigint-patch-2007-09-15.diff
File bigint-patch-2007-09-15.diff, 9.2 KB (added by , 17 years ago) |
---|
-
django/oldforms/__init__.py
763 763 if not 0 <= int(field_data) <= 32767: 764 764 raise validators.CriticalValidationError, ugettext("Enter a whole number between 0 and 32,767.") 765 765 766 class BigIntegerField(IntegerField): 767 def __init__(self, field_name, length=20, maxlength=None, is_required=False, validator_list=None, member_name=None): 768 if validator_list is None: validator_list = [] 769 validator_list = [self.isInteger] + validator_list 770 if member_name is not None: 771 self.member_name = member_name 772 IntegerField.__init__(self, field_name, length, maxlength, is_required, validator_list) 773 766 774 class FloatField(TextField): 767 775 def __init__(self, field_name, is_required=False, validator_list=None): 768 776 if validator_list is None: validator_list = [] -
django/db/models/fields/__init__.py
868 868 defaults.update(kwargs) 869 869 return super(IntegerField, self).formfield(**defaults) 870 870 871 class BigIntegerField(IntegerField): 872 MAX_BIGINT = 9223372036854775807 873 empty_strings_allowed = False 874 def get_manipulator_field_objs(self): 875 return [oldforms.BigIntegerField] 876 877 def get_db_prep_save(self, value): 878 if value > self.MAX_BIGINT or value < -self.MAX_BIGINT: 879 raise ValueError("Value is so small/large to fit to field") 880 return super(BigIntegerField, self).get_db_prep_save(value) 881 882 871 883 class IPAddressField(Field): 872 884 empty_strings_allowed = False 873 885 def __init__(self, *args, **kwargs): -
django/db/backends/ado_mssql/creation.py
11 11 'FloatField': 'double precision', 12 12 'ImageField': 'varchar(100)', 13 13 'IntegerField': 'int', 14 'BigIntegerField': 'bigint', 14 15 'IPAddressField': 'char(15)', 15 16 'NullBooleanField': 'bit', 16 17 'OneToOneField': 'int', -
django/db/backends/postgresql/introspection.py
71 71 # Maps type codes to Django Field types. 72 72 DATA_TYPES_REVERSE = { 73 73 16: 'BooleanField', 74 20: 'BigIntegerField', 74 75 21: 'SmallIntegerField', 75 76 23: 'IntegerField', 76 77 25: 'TextField', -
django/db/backends/postgresql/creation.py
15 15 'FloatField': 'double precision', 16 16 'ImageField': 'varchar(100)', 17 17 'IntegerField': 'integer', 18 'BigIntegerField': 'bigint', 18 19 'IPAddressField': 'inet', 19 20 'NullBooleanField': 'boolean', 20 21 'OneToOneField': 'integer', -
django/db/backends/sqlite3/introspection.py
64 64 'smallinteger': 'SmallIntegerField', 65 65 'int': 'IntegerField', 66 66 'integer': 'IntegerField', 67 'bigint': 'BigIntegerField', 67 68 'text': 'TextField', 68 69 'char': 'CharField', 69 70 'date': 'DateField', -
django/db/backends/sqlite3/creation.py
14 14 'FloatField': 'real', 15 15 'ImageField': 'varchar(100)', 16 16 'IntegerField': 'integer', 17 'BigIntegerField': 'bigint', 17 18 'IPAddressField': 'char(15)', 18 19 'NullBooleanField': 'bool', 19 20 'OneToOneField': 'integer', -
django/db/backends/mysql/introspection.py
84 84 FIELD_TYPE.FLOAT: 'FloatField', 85 85 FIELD_TYPE.INT24: 'IntegerField', 86 86 FIELD_TYPE.LONG: 'IntegerField', 87 FIELD_TYPE.LONGLONG: ' IntegerField',87 FIELD_TYPE.LONGLONG: 'BigIntegerField', 88 88 FIELD_TYPE.SHORT: 'IntegerField', 89 89 FIELD_TYPE.STRING: 'CharField', 90 90 FIELD_TYPE.TIMESTAMP: 'DateTimeField', -
django/db/backends/mysql/creation.py
15 15 'FloatField': 'double precision', 16 16 'ImageField': 'varchar(100)', 17 17 'IntegerField': 'integer', 18 'BigIntegerField': 'bigint', 18 19 'IPAddressField': 'char(15)', 19 20 'NullBooleanField': 'bool', 20 21 'OneToOneField': 'integer', -
django/db/backends/oracle/creation.py
18 18 'FloatField': 'DOUBLE PRECISION', 19 19 'ImageField': 'NVARCHAR2(100)', 20 20 'IntegerField': 'NUMBER(11)', 21 'BigIntegerField': 'NUMBER(19)', 21 22 'IPAddressField': 'VARCHAR2(15)', 22 23 'NullBooleanField': 'NUMBER(1) CHECK ((%(column)s IN (0,1)) OR (%(column)s IS NULL))', 23 24 'OneToOneField': 'NUMBER(11)', -
django/db/backends/postgresql_psycopg2/introspection.py
68 68 # Maps type codes to Django Field types. 69 69 DATA_TYPES_REVERSE = { 70 70 16: 'BooleanField', 71 20: 'BigIntegerField', 71 72 21: 'SmallIntegerField', 72 73 23: 'IntegerField', 73 74 25: 'TextField', -
django/contrib/admin/views/doc.py
303 303 'ForeignKey' : _('Integer'), 304 304 'ImageField' : _('File path'), 305 305 'IntegerField' : _('Integer'), 306 'BigIntegerField' : _('Integer'), 306 307 'IPAddressField' : _('IP address'), 307 308 'ManyToManyField' : '', 308 309 'NullBooleanField' : _('Boolean (Either True, False or None)'), -
tests/modeltests/field_types/models.py
1 """ 2 Tests for field type boundaries 3 """ 4 5 from django.db import models 6 7 class BigInt(models.Model): 8 value = models.BigIntegerField() 9 10 def __unicode__(self): 11 return unicode(self.value) 12 13 __test__ = {'API_TESTS': """ 14 >>> BigInt.objects.all() 15 [] 16 17 >>> t = BigInt(value = 0) 18 >>> t.save() 19 >>> t.value 20 0 21 22 >>> BigInt.objects.all() 23 [<BigInt: 0>] 24 25 >>> t = BigInt(value = -9223372036854775808) 26 >>> t.value 27 -9223372036854775808 28 29 >>> BigInt.objects.all().delete() 30 >>> t.save() 31 >>> BigInt.objects.all()[0] 32 <BigInt: -9223372036854775808> 33 34 >>> BigInt(value = -9223372036854775809111111111111111111).save() 35 Traceback (most recent call last): 36 ... 37 ValueError: Value is so small/large to fit to field 38 39 >>> BigInt(value = 9223372036854775808).save() 40 Traceback (most recent call last): 41 ... 42 ValueError: Value is so small/large to fit to field 43 44 >>> BigInt(value = 9223372036854775807).save() 45 >>> BigInt.objects.all() 46 [<BigInt: -9223372036854775808>, <BigInt: 9223372036854775807>] 47 """} 48 49 def test(): 50 import doctest 51 doctest.testmod() -
docs/model-api.txt
126 126 automatically be added to your model if you don't specify otherwise. See 127 127 `Automatic primary key fields`_. 128 128 129 ``BigIntegerField`` 130 ~~~~~~~~~~~~~~~~ 131 132 A big integer. 133 134 The admin represents this as an ``<input type="text">`` (a single-line input). 135 136 A 64 bit type like an ``IntegerField``, except that it fits numbers from 137 -9223372036854775808 to 9223372036854775807 138 129 139 ``BooleanField`` 130 140 ~~~~~~~~~~~~~~~~ 131 141