Adjusted refactoring of vendor checks.

Thanks Shai for the thorough review.
This commit is contained in:
Aymeric Augustin 2014-05-10 14:40:42 +02:00
parent a5de0df58b
commit fb90b7cda2
6 changed files with 11 additions and 10 deletions

View File

@ -518,8 +518,6 @@ class BaseDatabaseFeatures(object):
supports_subqueries_in_group_by = True
supports_bitwise_or = True
supports_boolean_type = True
supports_binary_field = True
# Do time/datetime fields have microsecond precision?
@ -581,6 +579,9 @@ class BaseDatabaseFeatures(object):
# Can the backend introspect an BinaryField, instead of an TextField?
can_introspect_binary_field = True
# Can the backend introspect an BooleanField, instead of an IntegerField?
can_introspect_boolean_field = True
# Can the backend introspect an IPAddressField, instead of an CharField?
can_introspect_ip_address_field = False
@ -639,7 +640,7 @@ class BaseDatabaseFeatures(object):
# Suffix for backends that don't support "SELECT xxx;" queries.
bare_select_suffix = ''
lowercases_column_names = False
uppercases_column_names = True
def __init__(self, connection):
self.connection = connection

View File

@ -172,13 +172,13 @@ class DatabaseFeatures(BaseDatabaseFeatures):
has_select_for_update_nowait = False
supports_forward_references = False
supports_long_model_names = False
supports_boolean_type = False
# XXX MySQL DB-API drivers currently fail on binary data on Python 3.
supports_binary_field = six.PY2
supports_microsecond_precision = False
supports_regex_backreferencing = False
supports_date_lookup_using_string = False
can_introspect_binary_field = False
can_introspect_boolean_field = False
supports_timezones = False
requires_explicit_null_ordering_when_grouping = True
allows_auto_pk_0 = False

View File

@ -120,7 +120,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
connection_persists_old_columns = True
closed_cursor_error_class = InterfaceError
bare_select_suffix = " FROM DUAL"
lowercases_column_names = True
uppercases_column_names = False
class DatabaseOperations(BaseDatabaseOperations):

View File

@ -87,7 +87,7 @@ class InspectDBTestCase(TestCase):
else:
assertFieldType('big_int_field', "models.IntegerField()")
if connection.features.supports_boolean_type:
if connection.features.can_introspect_boolean_field:
assertFieldType('bool_field', "models.BooleanField()")
assertFieldType('null_bool_field', "models.NullBooleanField()")
else:
@ -176,7 +176,7 @@ class InspectDBTestCase(TestCase):
out = StringIO()
call_command('inspectdb', stdout=out)
output = out.getvalue()
base_name = 'field' if connection.features.lowercases_column_names else 'Field'
base_name = 'field' if not connection.features.uppercases_column_names else 'Field'
self.assertIn("field = models.IntegerField()", output)
self.assertIn("field_field = models.IntegerField(db_column='%s_')" % base_name, output)
self.assertIn("field_field_0 = models.IntegerField(db_column='%s__')" % base_name, output)

View File

@ -57,7 +57,8 @@ class IntrospectionTests(TestCase):
self.assertEqual(
[datatype(r[1], r) for r in desc],
['AutoField' if connection.features.can_introspect_autofield else 'IntegerField',
'CharField', 'CharField', 'CharField', 'BigIntegerField',
'CharField', 'CharField', 'CharField',
'BigIntegerField' if connection.features.can_introspect_big_integer_field else 'IntegerField',
'BinaryField' if connection.features.can_introspect_binary_field else 'TextField']
)

View File

@ -449,6 +449,7 @@ class SerializerTests(TestCase):
self.assertEqual(base_data, proxy_proxy_data.replace('proxy', ''))
@skipUnlessDBFeature('supports_binary_field')
def serializerTest(format, self):
# Create all the objects defined in the test data
@ -481,8 +482,6 @@ def serializerTest(format, self):
for klass, count in instance_count.items():
self.assertEqual(count, klass.objects.count())
serializerTest = skipUnlessDBFeature('supports_binary_field')(serializerTest)
def naturalKeySerializerTest(format, self):
# Create all the objects defined in the test data