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 /tests/introspection | |
parent | a1d0c60fa05cbad2e5a25ec37e0afaf1b84c9302 (diff) | |
download | django-2a7ce34600d0f879e93c9a5e02215948ed3bb6ac.tar.gz |
Fixed #14286 -- Added models.BigAutoField.
Diffstat (limited to 'tests/introspection')
-rw-r--r-- | tests/introspection/models.py | 18 | ||||
-rw-r--r-- | tests/introspection/tests.py | 8 |
2 files changed, 25 insertions, 1 deletions
diff --git a/tests/introspection/models.py b/tests/introspection/models.py index 9ad52b8f8d..4d961b20be 100644 --- a/tests/introspection/models.py +++ b/tests/introspection/models.py @@ -5,6 +5,24 @@ from django.utils.encoding import python_2_unicode_compatible @python_2_unicode_compatible +class City(models.Model): + id = models.BigAutoField(primary_key=True) + name = models.CharField(max_length=50) + + def __str__(self): + return self.name + + +@python_2_unicode_compatible +class District(models.Model): + city = models.ForeignKey(City, models.CASCADE) + name = models.CharField(max_length=50) + + def __str__(self): + return self.name + + +@python_2_unicode_compatible class Reporter(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py index 3cd00060db..9ce5a3f0f6 100644 --- a/tests/introspection/tests.py +++ b/tests/introspection/tests.py @@ -6,7 +6,7 @@ from django.db import connection from django.db.utils import DatabaseError from django.test import TransactionTestCase, mock, skipUnlessDBFeature -from .models import Article, Reporter +from .models import Article, City, Reporter class IntrospectionTests(TransactionTestCase): @@ -103,6 +103,12 @@ class IntrospectionTests(TransactionTestCase): [False, nullable_by_backend, nullable_by_backend, nullable_by_backend, True, True, False] ) + @skipUnlessDBFeature('can_introspect_autofield') + def test_bigautofield(self): + with connection.cursor() as cursor: + desc = connection.introspection.get_table_description(cursor, City._meta.db_table) + self.assertIn('BigAutoField', [datatype(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): |