Ticket #14286: 14286-Add_BigAutoField.diff
File 14286-Add_BigAutoField.diff, 7.7 KB (added by , 14 years ago) |
---|
-
docs/topics/forms/modelforms.txt
49 49 Model field Form field 50 50 =============================== ======================================== 51 51 ``AutoField`` Not represented in the form 52 53 ``BigAutoField`` Not represented in the form 52 54 53 55 ``BigIntegerField`` ``IntegerField`` with ``min_value`` set 54 56 to -9223372036854775808 and ``max_value`` -
docs/ref/models/fields.txt
320 320 primary key field will automatically be added to your model if you don't specify 321 321 otherwise. See :ref:`automatic-primary-key-fields`. 322 322 323 ``BigAutoField`` 324 ---------------- 325 326 .. versionadded:: trunk 327 328 .. class:: BigAutoField(**options) 329 330 Behaves the same as :class:`AutoField` except it uses a :class:`BigIntegerField` 331 integer as the field. Use this field if you require a larger number of IDs than 332 :class:`AutoField` allows. 333 334 You may only have one instance of :class:`AutoField` or :class:`BigAutoField` 335 in your model. 336 323 337 ``BigIntegerField`` 324 338 ------------------- 325 339 -
django/db/models/fields/__init__.py
487 487 def formfield(self, **kwargs): 488 488 return None 489 489 490 class BigAutoField(AutoField): 491 description = _("Big (8 byte) integer") 492 493 def get_internal_type(self): 494 return "BigAutoField" 495 490 496 class BooleanField(Field): 491 497 empty_strings_allowed = False 492 498 default_error_messages = { -
django/db/models/fields/related.py
2 2 from django.db import connection, router, transaction 3 3 from django.db.backends import util 4 4 from django.db.models import signals, get_model 5 from django.db.models.fields import (AutoField, Field, IntegerField, 6 PositiveIntegerField, PositiveSmallIntegerField, FieldDoesNotExist) 5 from django.db.models.fields import (AutoField, BigAutoField, Field, 6 BigIntegerField, IntegerField, PositiveIntegerField, 7 PositiveSmallIntegerField, FieldDoesNotExist) 7 8 from django.db.models.related import RelatedObject 8 9 from django.db.models.query import QuerySet 9 10 from django.db.models.query_utils import QueryWrapper … … 919 920 def db_type(self, connection): 920 921 # The database column type of a ForeignKey is the column type 921 922 # of the field to which it points. An exception is if the ForeignKey 922 # points to an AutoField/PositiveIntegerField/PositiveSmallIntegerField, 923 # in which case the column type is simply that of an IntegerField. 923 # points to an AutoField/BigAutoField/PositiveIntegerField/ 924 # PositiveSmallIntegerField, 925 # in which case the column type is simply that of an IntegerField 926 # (or BigIntegerField in the case of BigAutoField). 924 927 # If the database needs similar types for key fields however, the only 925 # thing we can do is making AutoField an IntegerField. 928 # thing we can do is to make AutoField an IntegerField 929 # or BigAutoField a BigIntegerField 926 930 rel_field = self.rel.get_related_field() 931 if isinstance(rel_field, BigAutoField): 932 return BigIntegerField().db_type(connection=connection) 927 933 if (isinstance(rel_field, AutoField) or 928 934 (not connection.features.related_fields_match_type and 929 935 isinstance(rel_field, (PositiveIntegerField, -
django/db/backends/postgresql/creation.py
8 8 # If a column type is set to None, it won't be included in the output. 9 9 data_types = { 10 10 'AutoField': 'serial', 11 'BigAutoField': 'bigserial', 11 12 'BooleanField': 'boolean', 12 13 'CharField': 'varchar(%(max_length)s)', 13 14 'CommaSeparatedIntegerField': 'varchar(%(max_length)s)', -
django/db/backends/sqlite3/base.py
149 149 internal_type = field.get_internal_type() 150 150 if internal_type == 'DecimalField': 151 151 return util.typecast_decimal(field.format_number(value)) 152 elif internal_type and internal_type.endswith('IntegerField') or internal_type == 'AutoField':152 elif internal_type and internal_type.endswith('IntegerField') or internal_type.endswith('AutoField'): 153 153 return int(value) 154 154 elif internal_type == 'DateField': 155 155 return util.typecast_date(value) -
django/db/backends/sqlite3/creation.py
8 8 # schema inspection is more useful. 9 9 data_types = { 10 10 'AutoField': 'integer', 11 'BigAutoField': 'bigint', 11 12 'BooleanField': 'bool', 12 13 'CharField': 'varchar(%(max_length)s)', 13 14 'CommaSeparatedIntegerField': 'varchar(%(max_length)s)', -
django/db/backends/mysql/creation.py
7 7 # If a column type is set to None, it won't be included in the output. 8 8 data_types = { 9 9 'AutoField': 'integer AUTO_INCREMENT', 10 'BigAutoField': 'bigint AUTO_INCREMENT', 10 11 'BooleanField': 'bool', 11 12 'CharField': 'varchar(%(max_length)s)', 12 13 'CommaSeparatedIntegerField': 'varchar(%(max_length)s)', -
django/db/backends/oracle/creation.py
15 15 16 16 data_types = { 17 17 'AutoField': 'NUMBER(11)', 18 'BigAutoField': 'NUMBER(19)', 18 19 'BooleanField': 'NUMBER(1) CHECK (%(qn_column)s IN (0,1))', 19 20 'CharField': 'NVARCHAR2(%(max_length)s)', 20 21 'CommaSeparatedIntegerField': 'VARCHAR2(%(max_length)s)', -
django/db/backends/__init__.py
565 565 internal_type = field.get_internal_type() 566 566 if internal_type == 'DecimalField': 567 567 return value 568 elif internal_type and internal_type.endswith('IntegerField') or internal_type == 'AutoField':568 elif internal_type and internal_type.endswith('IntegerField') or internal_type.endswith('AutoField'): 569 569 return int(value) 570 570 elif internal_type in ('DateField', 'DateTimeField', 'TimeField'): 571 571 return value