summaryrefslogtreecommitdiff
path: root/tests/introspection
diff options
context:
space:
mode:
authorNick Pope <nick.pope@flightdataservices.com>2019-07-26 22:05:22 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-08-02 11:39:01 +0200
commit194d1dfc186cc8d2b35dabf64f3ed38b757cbd98 (patch)
tree51ffabb34edc5b191ce8079c9149b77c88c2749e /tests/introspection
parent955b382600e4626265cc20e5773bdbcfd01fc4af (diff)
downloaddjango-194d1dfc186cc8d2b35dabf64f3ed38b757cbd98.tar.gz
Fixed #30661 -- Added models.SmallAutoField.
Diffstat (limited to 'tests/introspection')
-rw-r--r--tests/introspection/models.py5
-rw-r--r--tests/introspection/tests.py13
2 files changed, 17 insertions, 1 deletions
diff --git a/tests/introspection/models.py b/tests/introspection/models.py
index fa663de2fd..d069c5820e 100644
--- a/tests/introspection/models.py
+++ b/tests/introspection/models.py
@@ -9,6 +9,11 @@ class City(models.Model):
return self.name
+class Country(models.Model):
+ id = models.SmallAutoField(primary_key=True)
+ name = models.CharField(max_length=50)
+
+
class District(models.Model):
city = models.ForeignKey(City, models.CASCADE, primary_key=True)
name = models.CharField(max_length=50)
diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py
index 7edb01a4b7..4a7ce11e7a 100644
--- a/tests/introspection/tests.py
+++ b/tests/introspection/tests.py
@@ -5,7 +5,9 @@ from django.db.models import Index
from django.db.utils import DatabaseError
from django.test import TransactionTestCase, skipUnlessDBFeature
-from .models import Article, ArticleReporter, City, Comment, District, Reporter
+from .models import (
+ Article, ArticleReporter, City, Comment, Country, District, Reporter,
+)
class IntrospectionTests(TransactionTestCase):
@@ -115,6 +117,15 @@ class IntrospectionTests(TransactionTestCase):
[connection.introspection.get_field_type(r[1], r) for r in desc],
)
+ @skipUnlessDBFeature('can_introspect_autofield')
+ def test_smallautofield(self):
+ with connection.cursor() as cursor:
+ desc = connection.introspection.get_table_description(cursor, Country._meta.db_table)
+ self.assertIn(
+ connection.features.introspected_small_auto_field_type,
+ [connection.introspection.get_field_type(r[1], r) for r in desc],
+ )
+
# Regression test for #9991 - 'real' types in postgres
@skipUnlessDBFeature('has_real_datatype')
def test_postgresql_real_type(self):