Skip to content

Commit

Permalink
Adjusted refactoring of vendor checks.
Browse files Browse the repository at this point in the history
Thanks Shai for the thorough review.
  • Loading branch information
aaugustin committed May 10, 2014
1 parent a5de0df commit fb90b7c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions django/db/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion django/db/backends/mysql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion django/db/backends/oracle/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/inspectdb/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_number_field_types(self):
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:
Expand Down Expand Up @@ -176,7 +176,7 @@ def test_special_column_name_introspection(self):
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)
Expand Down
3 changes: 2 additions & 1 deletion tests/introspection/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def test_get_table_description_types(self):
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']
)

Expand Down
3 changes: 1 addition & 2 deletions tests/serializers_regress/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ def test_serialize_proxy_model(self):
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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fb90b7c

Please sign in to comment.