Refs #31630 -- Removed DatabaseFeatures.can_introspect_autofield.

This commit is contained in:
Tim Graham 2020-06-01 20:18:14 -04:00 committed by Mariusz Felisiak
parent e198beadad
commit e24b63fe85
8 changed files with 7 additions and 12 deletions

View File

@ -142,7 +142,7 @@ class Command(BaseCommand):
if att_name == 'id' and extra_params == {'primary_key': True}:
if field_type == 'AutoField(':
continue
elif field_type == 'IntegerField(' and not connection.features.can_introspect_autofield:
elif field_type == connection.features.introspected_field_types['AutoField'] + '(':
comment_notes.append('AutoField?')
# Add 'null' and 'blank', if the 'null_ok' flag was present in the

View File

@ -125,12 +125,10 @@ class BaseDatabaseFeatures:
# which can't do it for MyISAM tables
can_introspect_foreign_keys = True
# Can the backend introspect an AutoField, instead of an IntegerField?
can_introspect_autofield = False
# Map fields which some backends may not be able to differentiate to the
# field it's introspected as.
introspected_field_types = {
'AutoField': 'AutoField',
'BigAutoField': 'BigAutoField',
'BigIntegerField': 'BigIntegerField',
'BinaryField': 'BinaryField',

View File

@ -14,7 +14,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
supports_forward_references = False
supports_regex_backreferencing = False
supports_date_lookup_using_string = False
can_introspect_autofield = True
supports_index_column_ordering = False
supports_timezones = False
requires_explicit_null_ordering_when_grouping = True

View File

@ -11,7 +11,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
has_select_for_update_of = True
select_for_update_of_column = True
can_return_columns_from_insert = True
can_introspect_autofield = True
supports_subqueries_in_group_by = False
supports_transactions = True
supports_timezones = False

View File

@ -18,7 +18,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
supports_timezones = False
max_query_params = 999
supports_mixed_date_datetime_comparisons = False
can_introspect_autofield = True
supports_transactions = True
atomic_transactions = False
can_rollback_ddl = True

View File

@ -250,6 +250,7 @@ backends.
* The new ``DatabaseFeatures.introspected_field_types`` property replaces these
features:
* ``can_introspect_autofield``
* ``can_introspect_big_integer_field``
* ``can_introspect_binary_field``
* ``can_introspect_decimal_field``

View File

@ -99,8 +99,9 @@ class InspectDBTestCase(TestCase):
assertFieldType = self.make_field_type_asserter()
introspected_field_types = connection.features.introspected_field_types
if not connection.features.can_introspect_autofield:
assertFieldType('id', "models.IntegerField(primary_key=True) # AutoField?")
auto_field_type = connection.features.introspected_field_types['AutoField']
if auto_field_type != 'AutoField':
assertFieldType('id', "models.%s(primary_key=True) # AutoField?" % auto_field_type)
assertFieldType('big_int_field', 'models.%s()' % introspected_field_types['BigIntegerField'])

View File

@ -80,7 +80,7 @@ class IntrospectionTests(TransactionTestCase):
self.assertEqual(
[connection.introspection.get_field_type(r[1], r) for r in desc],
[
'AutoField' if connection.features.can_introspect_autofield else 'IntegerField',
connection.features.introspected_field_types['AutoField'],
'CharField',
'CharField',
'CharField',
@ -108,7 +108,6 @@ class IntrospectionTests(TransactionTestCase):
[False, nullable_by_backend, nullable_by_backend, nullable_by_backend, True, True, False, 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)
@ -117,7 +116,6 @@ 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)