diff options
| author | Alexander Sosnovskiy <alecs.box@gmail.com> | 2015-07-02 11:43:15 +0300 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-12-25 20:01:31 -0500 |
| commit | 2a7ce34600d0f879e93c9a5e02215948ed3bb6ac (patch) | |
| tree | d1a4770772b452513e1d64c090dc15ae287afe70 /django/db/backends/postgresql | |
| parent | a1d0c60fa05cbad2e5a25ec37e0afaf1b84c9302 (diff) | |
Fixed #14286 -- Added models.BigAutoField.
Diffstat (limited to 'django/db/backends/postgresql')
| -rw-r--r-- | django/db/backends/postgresql/base.py | 1 | ||||
| -rw-r--r-- | django/db/backends/postgresql/introspection.py | 7 | ||||
| -rw-r--r-- | django/db/backends/postgresql/schema.py | 5 |
3 files changed, 9 insertions, 4 deletions
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index 383601e477..7822c66327 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -72,6 +72,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): # If a column type is set to None, it won't be included in the output. data_types = { 'AutoField': 'serial', + 'BigAutoField': 'bigserial', 'BinaryField': 'bytea', 'BooleanField': 'boolean', 'CharField': 'varchar(%(max_length)s)', diff --git a/django/db/backends/postgresql/introspection.py b/django/db/backends/postgresql/introspection.py index 9b3e9074b2..90b7090464 100644 --- a/django/db/backends/postgresql/introspection.py +++ b/django/db/backends/postgresql/introspection.py @@ -46,8 +46,11 @@ 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 description.default and 'nextval' in description.default: - return 'AutoField' + if description.default and 'nextval' in description.default: + if field_type == 'IntegerField': + return 'AutoField' + elif field_type == 'BigIntegerField': + return 'BigAutoField' return field_type def get_table_list(self, cursor): diff --git a/django/db/backends/postgresql/schema.py b/django/db/backends/postgresql/schema.py index cc31aadf0a..42d01f002d 100644 --- a/django/db/backends/postgresql/schema.py +++ b/django/db/backends/postgresql/schema.py @@ -54,14 +54,15 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): """ Makes ALTER TYPE with SERIAL make sense. """ - if new_type.lower() == "serial": + if new_type.lower() in ("serial", "bigserial"): column = new_field.column sequence_name = "%s_%s_seq" % (table, column) + col_type = "integer" if new_type.lower() == "serial" else "bigint" return ( ( self.sql_alter_column_type % { "column": self.quote_name(column), - "type": "integer", + "type": col_type, }, [], ), |
