diff options
| author | Karen Tracey <kmtracey@gmail.com> | 2009-12-17 15:10:38 +0000 |
|---|---|---|
| committer | Karen Tracey <kmtracey@gmail.com> | 2009-12-17 15:10:38 +0000 |
| commit | 5bd63663a9754ef783aa21402f534fe6ed45ef57 (patch) | |
| tree | e12689d4bf10f59b135dbb627b1ecb0b9d5a092c /django | |
| parent | fd4cc65baf7055e7815513756a3d3f6940c1d2ab (diff) | |
Fixed #399: Added big integer field. Thanks to Tomáš Kopeček for persistently maintaining a patch for this.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11887 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admin/options.py | 17 | ||||
| -rw-r--r-- | django/db/backends/mysql/creation.py | 1 | ||||
| -rw-r--r-- | django/db/backends/mysql/introspection.py | 2 | ||||
| -rw-r--r-- | django/db/backends/oracle/creation.py | 1 | ||||
| -rw-r--r-- | django/db/backends/oracle/introspection.py | 5 | ||||
| -rw-r--r-- | django/db/backends/postgresql/creation.py | 1 | ||||
| -rw-r--r-- | django/db/backends/postgresql/introspection.py | 1 | ||||
| -rw-r--r-- | django/db/backends/sqlite3/creation.py | 1 | ||||
| -rw-r--r-- | django/db/backends/sqlite3/introspection.py | 1 | ||||
| -rw-r--r-- | django/db/models/fields/__init__.py | 13 |
10 files changed, 33 insertions, 10 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 2d04bbbc4b..c9d4f33884 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -42,14 +42,15 @@ FORMFIELD_FOR_DBFIELD_DEFAULTS = { 'form_class': forms.SplitDateTimeField, 'widget': widgets.AdminSplitDateTime }, - models.DateField: {'widget': widgets.AdminDateWidget}, - models.TimeField: {'widget': widgets.AdminTimeWidget}, - models.TextField: {'widget': widgets.AdminTextareaWidget}, - models.URLField: {'widget': widgets.AdminURLFieldWidget}, - models.IntegerField: {'widget': widgets.AdminIntegerFieldWidget}, - models.CharField: {'widget': widgets.AdminTextInputWidget}, - models.ImageField: {'widget': widgets.AdminFileWidget}, - models.FileField: {'widget': widgets.AdminFileWidget}, + models.DateField: {'widget': widgets.AdminDateWidget}, + models.TimeField: {'widget': widgets.AdminTimeWidget}, + models.TextField: {'widget': widgets.AdminTextareaWidget}, + models.URLField: {'widget': widgets.AdminURLFieldWidget}, + models.IntegerField: {'widget': widgets.AdminIntegerFieldWidget}, + models.BigIntegerField: {'widget': widgets.AdminIntegerFieldWidget}, + models.CharField: {'widget': widgets.AdminTextInputWidget}, + models.ImageField: {'widget': widgets.AdminFileWidget}, + models.FileField: {'widget': widgets.AdminFileWidget}, } diff --git a/django/db/backends/mysql/creation.py b/django/db/backends/mysql/creation.py index 0611e01643..063ba4c712 100644 --- a/django/db/backends/mysql/creation.py +++ b/django/db/backends/mysql/creation.py @@ -18,6 +18,7 @@ class DatabaseCreation(BaseDatabaseCreation): 'FilePathField': 'varchar(%(max_length)s)', 'FloatField': 'double precision', 'IntegerField': 'integer', + 'BigIntegerField': 'bigint', 'IPAddressField': 'char(15)', 'NullBooleanField': 'bool', 'OneToOneField': 'integer', diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py index d8d59b73a1..9e1518b06e 100644 --- a/django/db/backends/mysql/introspection.py +++ b/django/db/backends/mysql/introspection.py @@ -17,7 +17,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): FIELD_TYPE.FLOAT: 'FloatField', FIELD_TYPE.INT24: 'IntegerField', FIELD_TYPE.LONG: 'IntegerField', - FIELD_TYPE.LONGLONG: 'IntegerField', + FIELD_TYPE.LONGLONG: 'BigIntegerField', FIELD_TYPE.SHORT: 'IntegerField', FIELD_TYPE.STRING: 'CharField', FIELD_TYPE.TIMESTAMP: 'DateTimeField', diff --git a/django/db/backends/oracle/creation.py b/django/db/backends/oracle/creation.py index 43d8760fca..86d84ca5a6 100644 --- a/django/db/backends/oracle/creation.py +++ b/django/db/backends/oracle/creation.py @@ -27,6 +27,7 @@ class DatabaseCreation(BaseDatabaseCreation): 'FilePathField': 'NVARCHAR2(%(max_length)s)', 'FloatField': 'DOUBLE PRECISION', 'IntegerField': 'NUMBER(11)', + 'BigIntegerField': 'NUMBER(19)', 'IPAddressField': 'VARCHAR2(15)', 'NullBooleanField': 'NUMBER(1) CHECK ((%(qn_column)s IN (0,1)) OR (%(qn_column)s IS NULL))', 'OneToOneField': 'NUMBER(11)', diff --git a/django/db/backends/oracle/introspection.py b/django/db/backends/oracle/introspection.py index 0b4f61a360..0dd0304302 100644 --- a/django/db/backends/oracle/introspection.py +++ b/django/db/backends/oracle/introspection.py @@ -29,7 +29,10 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): def get_field_type(self, data_type, description): # If it's a NUMBER with scale == 0, consider it an IntegerField if data_type == cx_Oracle.NUMBER and description[5] == 0: - return 'IntegerField' + if description[4] > 11: + return 'BigIntegerField' + else: + return 'IntegerField' else: return super(DatabaseIntrospection, self).get_field_type( data_type, description) diff --git a/django/db/backends/postgresql/creation.py b/django/db/backends/postgresql/creation.py index 8f329feca4..0940c7eb71 100644 --- a/django/db/backends/postgresql/creation.py +++ b/django/db/backends/postgresql/creation.py @@ -18,6 +18,7 @@ class DatabaseCreation(BaseDatabaseCreation): 'FilePathField': 'varchar(%(max_length)s)', 'FloatField': 'double precision', 'IntegerField': 'integer', + 'BigIntegerField': 'bigint', 'IPAddressField': 'inet', 'NullBooleanField': 'boolean', 'OneToOneField': 'integer', diff --git a/django/db/backends/postgresql/introspection.py b/django/db/backends/postgresql/introspection.py index a6cafcd949..534bf41d46 100644 --- a/django/db/backends/postgresql/introspection.py +++ b/django/db/backends/postgresql/introspection.py @@ -4,6 +4,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): # Maps type codes to Django Field types. data_types_reverse = { 16: 'BooleanField', + 20: 'BigIntegerField', 21: 'SmallIntegerField', 23: 'IntegerField', 25: 'TextField', diff --git a/django/db/backends/sqlite3/creation.py b/django/db/backends/sqlite3/creation.py index e9e0a94634..fb27d22cf3 100644 --- a/django/db/backends/sqlite3/creation.py +++ b/django/db/backends/sqlite3/creation.py @@ -19,6 +19,7 @@ class DatabaseCreation(BaseDatabaseCreation): 'FilePathField': 'varchar(%(max_length)s)', 'FloatField': 'real', 'IntegerField': 'integer', + 'BigIntegerField': 'bigint', 'IPAddressField': 'char(15)', 'NullBooleanField': 'bool', 'OneToOneField': 'integer', diff --git a/django/db/backends/sqlite3/introspection.py b/django/db/backends/sqlite3/introspection.py index b58e6a7faf..ce64908873 100644 --- a/django/db/backends/sqlite3/introspection.py +++ b/django/db/backends/sqlite3/introspection.py @@ -16,6 +16,7 @@ class FlexibleFieldLookupDict: 'smallinteger': 'SmallIntegerField', 'int': 'IntegerField', 'integer': 'IntegerField', + 'bigint': 'BigIntegerField', 'integer unsigned': 'PositiveIntegerField', 'decimal': 'DecimalField', 'real': 'FloatField', diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index b5fd30e47c..ea10b801f6 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -732,6 +732,19 @@ class IntegerField(Field): defaults.update(kwargs) return super(IntegerField, self).formfield(**defaults) +class BigIntegerField(IntegerField): + empty_strings_allowed = False + description = ugettext_lazy("Big (8 byte) integer") + MAX_BIGINT = 9223372036854775807 + def get_internal_type(self): + return "BigIntegerField" + + def formfield(self, **kwargs): + defaults = {'min_value': -BigIntegerField.MAX_BIGINT - 1, + 'max_value': BigIntegerField.MAX_BIGINT} + defaults.update(kwargs) + return super(BigIntegerField, self).formfield(**defaults) + class IPAddressField(Field): empty_strings_allowed = False description = ugettext_lazy("IP address") |
