mirror of https://github.com/django/django.git
Fixed #32132 -- Fixed column types in m2m intermediary tables for Positive(Big/Small)IntegerFields.
This commit is contained in:
parent
4ebd633350
commit
cfc7cd6513
|
@ -1864,6 +1864,13 @@ class BigIntegerField(IntegerField):
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
class SmallIntegerField(IntegerField):
|
||||||
|
description = _('Small integer')
|
||||||
|
|
||||||
|
def get_internal_type(self):
|
||||||
|
return 'SmallIntegerField'
|
||||||
|
|
||||||
|
|
||||||
class IPAddressField(Field):
|
class IPAddressField(Field):
|
||||||
empty_strings_allowed = False
|
empty_strings_allowed = False
|
||||||
description = _("IPv4 address")
|
description = _("IPv4 address")
|
||||||
|
@ -2006,6 +2013,17 @@ class NullBooleanField(BooleanField):
|
||||||
|
|
||||||
|
|
||||||
class PositiveIntegerRelDbTypeMixin:
|
class PositiveIntegerRelDbTypeMixin:
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
if not hasattr(cls, 'integer_field_class'):
|
||||||
|
cls.integer_field_class = next(
|
||||||
|
(
|
||||||
|
parent
|
||||||
|
for parent in cls.__mro__[1:]
|
||||||
|
if issubclass(parent, IntegerField)
|
||||||
|
),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
|
||||||
def rel_db_type(self, connection):
|
def rel_db_type(self, connection):
|
||||||
"""
|
"""
|
||||||
|
@ -2019,10 +2037,10 @@ class PositiveIntegerRelDbTypeMixin:
|
||||||
if connection.features.related_fields_match_type:
|
if connection.features.related_fields_match_type:
|
||||||
return self.db_type(connection)
|
return self.db_type(connection)
|
||||||
else:
|
else:
|
||||||
return IntegerField().db_type(connection=connection)
|
return self.integer_field_class().db_type(connection=connection)
|
||||||
|
|
||||||
|
|
||||||
class PositiveBigIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField):
|
class PositiveBigIntegerField(PositiveIntegerRelDbTypeMixin, BigIntegerField):
|
||||||
description = _('Positive big integer')
|
description = _('Positive big integer')
|
||||||
|
|
||||||
def get_internal_type(self):
|
def get_internal_type(self):
|
||||||
|
@ -2048,7 +2066,7 @@ class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField):
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField):
|
class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, SmallIntegerField):
|
||||||
description = _("Positive small integer")
|
description = _("Positive small integer")
|
||||||
|
|
||||||
def get_internal_type(self):
|
def get_internal_type(self):
|
||||||
|
@ -2094,13 +2112,6 @@ class SlugField(CharField):
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class SmallIntegerField(IntegerField):
|
|
||||||
description = _("Small integer")
|
|
||||||
|
|
||||||
def get_internal_type(self):
|
|
||||||
return "SmallIntegerField"
|
|
||||||
|
|
||||||
|
|
||||||
class TextField(Field):
|
class TextField(Field):
|
||||||
description = _("Text")
|
description = _("Text")
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,11 @@ class BigIntegerFieldTests(IntegerFieldTests):
|
||||||
class PositiveSmallIntegerFieldTests(IntegerFieldTests):
|
class PositiveSmallIntegerFieldTests(IntegerFieldTests):
|
||||||
model = PositiveSmallIntegerModel
|
model = PositiveSmallIntegerModel
|
||||||
documented_range = (0, 32767)
|
documented_range = (0, 32767)
|
||||||
|
rel_db_type_class = (
|
||||||
|
models.PositiveSmallIntegerField
|
||||||
|
if connection.features.related_fields_match_type
|
||||||
|
else models.SmallIntegerField
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class PositiveIntegerFieldTests(IntegerFieldTests):
|
class PositiveIntegerFieldTests(IntegerFieldTests):
|
||||||
|
@ -198,6 +203,11 @@ class PositiveIntegerFieldTests(IntegerFieldTests):
|
||||||
class PositiveBigIntegerFieldTests(IntegerFieldTests):
|
class PositiveBigIntegerFieldTests(IntegerFieldTests):
|
||||||
model = PositiveBigIntegerModel
|
model = PositiveBigIntegerModel
|
||||||
documented_range = (0, 9223372036854775807)
|
documented_range = (0, 9223372036854775807)
|
||||||
|
rel_db_type_class = (
|
||||||
|
models.PositiveBigIntegerField
|
||||||
|
if connection.features.related_fields_match_type
|
||||||
|
else models.BigIntegerField
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ValidationTests(SimpleTestCase):
|
class ValidationTests(SimpleTestCase):
|
||||||
|
|
Loading…
Reference in New Issue