diff options
| author | Nick Pope <nick.pope@flightdataservices.com> | 2019-07-26 22:05:22 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-08-02 11:39:01 +0200 |
| commit | 194d1dfc186cc8d2b35dabf64f3ed38b757cbd98 (patch) | |
| tree | 51ffabb34edc5b191ce8079c9149b77c88c2749e /django/db/backends/sqlite3 | |
| parent | 955b382600e4626265cc20e5773bdbcfd01fc4af (diff) | |
Fixed #30661 -- Added models.SmallAutoField.
Diffstat (limited to 'django/db/backends/sqlite3')
| -rw-r--r-- | django/db/backends/sqlite3/base.py | 2 | ||||
| -rw-r--r-- | django/db/backends/sqlite3/features.py | 1 | ||||
| -rw-r--r-- | django/db/backends/sqlite3/introspection.py | 6 |
3 files changed, 6 insertions, 3 deletions
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index fff65197f9..7a4439ae88 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -104,6 +104,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): 'PositiveIntegerField': 'integer unsigned', 'PositiveSmallIntegerField': 'smallint unsigned', 'SlugField': 'varchar(%(max_length)s)', + 'SmallAutoField': 'integer', 'SmallIntegerField': 'smallint', 'TextField': 'text', 'TimeField': 'time', @@ -116,6 +117,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): data_types_suffix = { 'AutoField': 'AUTOINCREMENT', 'BigAutoField': 'AUTOINCREMENT', + 'SmallAutoField': 'AUTOINCREMENT', } # SQLite requires LIKE statements to include an ESCAPE clause if the value # being escaped has a percent or underscore in it. diff --git a/django/db/backends/sqlite3/features.py b/django/db/backends/sqlite3/features.py index 3d52a8036f..18b76f8c86 100644 --- a/django/db/backends/sqlite3/features.py +++ b/django/db/backends/sqlite3/features.py @@ -19,6 +19,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): can_introspect_positive_integer_field = True can_introspect_small_integer_field = True introspected_big_auto_field_type = 'AutoField' + introspected_small_auto_field_type = 'AutoField' supports_transactions = True atomic_transactions = False can_rollback_ddl = True diff --git a/django/db/backends/sqlite3/introspection.py b/django/db/backends/sqlite3/introspection.py index faf9328415..5e33d2a7e2 100644 --- a/django/db/backends/sqlite3/introspection.py +++ b/django/db/backends/sqlite3/introspection.py @@ -57,9 +57,9 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): def get_field_type(self, data_type, description): field_type = super().get_field_type(data_type, description) - if description.pk and field_type in {'BigIntegerField', 'IntegerField'}: - # No support for BigAutoField as SQLite treats all integer primary - # keys as signed 64-bit integers. + if description.pk and field_type in {'BigIntegerField', 'IntegerField', 'SmallIntegerField'}: + # No support for BigAutoField or SmallAutoField as SQLite treats + # all integer primary keys as signed 64-bit integers. return 'AutoField' return field_type |
