Commit 2a7ce346 authored by Alexander Sosnovskiy's avatar Alexander Sosnovskiy Committed by Tim Graham
Browse files

Fixed #14286 -- Added models.BigAutoField.

parent a1d0c60f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -15,7 +15,8 @@ from django.contrib.gis.gdal import (
    SpatialReference,
)
from django.contrib.gis.gdal.field import (
    OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime,
    OFTDate, OFTDateTime, OFTInteger, OFTInteger64, OFTReal, OFTString,
    OFTTime,
)
from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist
from django.db import connections, models, router, transaction
@@ -60,6 +61,7 @@ class LayerMapping(object):
    # counterparts.
    FIELD_TYPES = {
        models.AutoField: OFTInteger,
        models.BigAutoField: OFTInteger64,
        models.IntegerField: (OFTInteger, OFTReal, OFTString),
        models.FloatField: (OFTInteger, OFTReal),
        models.DateField: OFTDate,
+1 −1
Original line number Diff line number Diff line
@@ -261,7 +261,7 @@ class BaseDatabaseSchemaEditor(object):
                definition,
            ))
            # Autoincrement SQL (for backends with post table definition variant)
            if field.get_internal_type() == "AutoField":
            if field.get_internal_type() in ("AutoField", "BigAutoField"):
                autoinc_sql = self.connection.ops.autoinc_sql(model._meta.db_table, field.column)
                if autoinc_sql:
                    self.deferred_sql.extend(autoinc_sql)
+1 −0
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
    # If a column type is set to None, it won't be included in the output.
    _data_types = {
        'AutoField': 'integer AUTO_INCREMENT',
        'BigAutoField': 'bigint AUTO_INCREMENT',
        'BinaryField': 'longblob',
        'BooleanField': 'bool',
        'CharField': 'varchar(%(max_length)s)',
+6 −2
Original line number Diff line number Diff line
@@ -38,8 +38,12 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):

    def get_field_type(self, data_type, description):
        field_type = super(DatabaseIntrospection, self).get_field_type(data_type, description)
        if field_type == 'IntegerField' and 'auto_increment' in description.extra:
        if 'auto_increment' in description.extra:
            if field_type == 'IntegerField':
                return 'AutoField'
            elif field_type == 'BigIntegerField':
                return 'BigAutoField'

        return field_type

    def get_table_list(self, cursor):
+1 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
    # output (the "qn_" prefix is stripped before the lookup is performed.
    data_types = {
        'AutoField': 'NUMBER(11)',
        'BigAutoField': 'NUMBER(19)',
        'BinaryField': 'BLOB',
        'BooleanField': 'NUMBER(1)',
        'CharField': 'NVARCHAR2(%(max_length)s)',
Loading