Refs #31630 -- Removed DatabaseFeatures.can_introspect_autofield.
This commit is contained in:
parent
e198beadad
commit
e24b63fe85
|
@ -142,7 +142,7 @@ class Command(BaseCommand):
|
||||||
if att_name == 'id' and extra_params == {'primary_key': True}:
|
if att_name == 'id' and extra_params == {'primary_key': True}:
|
||||||
if field_type == 'AutoField(':
|
if field_type == 'AutoField(':
|
||||||
continue
|
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?')
|
comment_notes.append('AutoField?')
|
||||||
|
|
||||||
# Add 'null' and 'blank', if the 'null_ok' flag was present in the
|
# Add 'null' and 'blank', if the 'null_ok' flag was present in the
|
||||||
|
|
|
@ -125,12 +125,10 @@ class BaseDatabaseFeatures:
|
||||||
# which can't do it for MyISAM tables
|
# which can't do it for MyISAM tables
|
||||||
can_introspect_foreign_keys = True
|
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
|
# Map fields which some backends may not be able to differentiate to the
|
||||||
# field it's introspected as.
|
# field it's introspected as.
|
||||||
introspected_field_types = {
|
introspected_field_types = {
|
||||||
|
'AutoField': 'AutoField',
|
||||||
'BigAutoField': 'BigAutoField',
|
'BigAutoField': 'BigAutoField',
|
||||||
'BigIntegerField': 'BigIntegerField',
|
'BigIntegerField': 'BigIntegerField',
|
||||||
'BinaryField': 'BinaryField',
|
'BinaryField': 'BinaryField',
|
||||||
|
|
|
@ -14,7 +14,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
||||||
supports_forward_references = False
|
supports_forward_references = False
|
||||||
supports_regex_backreferencing = False
|
supports_regex_backreferencing = False
|
||||||
supports_date_lookup_using_string = False
|
supports_date_lookup_using_string = False
|
||||||
can_introspect_autofield = True
|
|
||||||
supports_index_column_ordering = False
|
supports_index_column_ordering = False
|
||||||
supports_timezones = False
|
supports_timezones = False
|
||||||
requires_explicit_null_ordering_when_grouping = True
|
requires_explicit_null_ordering_when_grouping = True
|
||||||
|
|
|
@ -11,7 +11,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
||||||
has_select_for_update_of = True
|
has_select_for_update_of = True
|
||||||
select_for_update_of_column = True
|
select_for_update_of_column = True
|
||||||
can_return_columns_from_insert = True
|
can_return_columns_from_insert = True
|
||||||
can_introspect_autofield = True
|
|
||||||
supports_subqueries_in_group_by = False
|
supports_subqueries_in_group_by = False
|
||||||
supports_transactions = True
|
supports_transactions = True
|
||||||
supports_timezones = False
|
supports_timezones = False
|
||||||
|
|
|
@ -18,7 +18,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
||||||
supports_timezones = False
|
supports_timezones = False
|
||||||
max_query_params = 999
|
max_query_params = 999
|
||||||
supports_mixed_date_datetime_comparisons = False
|
supports_mixed_date_datetime_comparisons = False
|
||||||
can_introspect_autofield = True
|
|
||||||
supports_transactions = True
|
supports_transactions = True
|
||||||
atomic_transactions = False
|
atomic_transactions = False
|
||||||
can_rollback_ddl = True
|
can_rollback_ddl = True
|
||||||
|
|
|
@ -250,6 +250,7 @@ backends.
|
||||||
* The new ``DatabaseFeatures.introspected_field_types`` property replaces these
|
* The new ``DatabaseFeatures.introspected_field_types`` property replaces these
|
||||||
features:
|
features:
|
||||||
|
|
||||||
|
* ``can_introspect_autofield``
|
||||||
* ``can_introspect_big_integer_field``
|
* ``can_introspect_big_integer_field``
|
||||||
* ``can_introspect_binary_field``
|
* ``can_introspect_binary_field``
|
||||||
* ``can_introspect_decimal_field``
|
* ``can_introspect_decimal_field``
|
||||||
|
|
|
@ -99,8 +99,9 @@ class InspectDBTestCase(TestCase):
|
||||||
assertFieldType = self.make_field_type_asserter()
|
assertFieldType = self.make_field_type_asserter()
|
||||||
introspected_field_types = connection.features.introspected_field_types
|
introspected_field_types = connection.features.introspected_field_types
|
||||||
|
|
||||||
if not connection.features.can_introspect_autofield:
|
auto_field_type = connection.features.introspected_field_types['AutoField']
|
||||||
assertFieldType('id', "models.IntegerField(primary_key=True) # 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'])
|
assertFieldType('big_int_field', 'models.%s()' % introspected_field_types['BigIntegerField'])
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ class IntrospectionTests(TransactionTestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[connection.introspection.get_field_type(r[1], r) for r in desc],
|
[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',
|
'CharField',
|
||||||
'CharField',
|
'CharField',
|
||||||
|
@ -108,7 +108,6 @@ class IntrospectionTests(TransactionTestCase):
|
||||||
[False, nullable_by_backend, nullable_by_backend, nullable_by_backend, True, True, False, False]
|
[False, nullable_by_backend, nullable_by_backend, nullable_by_backend, True, True, False, False]
|
||||||
)
|
)
|
||||||
|
|
||||||
@skipUnlessDBFeature('can_introspect_autofield')
|
|
||||||
def test_bigautofield(self):
|
def test_bigautofield(self):
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
desc = connection.introspection.get_table_description(cursor, City._meta.db_table)
|
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],
|
[connection.introspection.get_field_type(r[1], r) for r in desc],
|
||||||
)
|
)
|
||||||
|
|
||||||
@skipUnlessDBFeature('can_introspect_autofield')
|
|
||||||
def test_smallautofield(self):
|
def test_smallautofield(self):
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
desc = connection.introspection.get_table_description(cursor, Country._meta.db_table)
|
desc = connection.introspection.get_table_description(cursor, Country._meta.db_table)
|
||||||
|
|
Loading…
Reference in New Issue