mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #30661 -- Added models.SmallAutoField.
This commit is contained in:
parent
955b382600
commit
194d1dfc18
28 changed files with 177 additions and 26 deletions
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue