diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-05-10 14:40:42 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-05-10 14:55:22 +0200 |
| commit | c54fb3d922fdcd00c4e17676fe4cdaa3a3f6f6d8 (patch) | |
| tree | 88e6edda8c6298f3eba44032e11010ba8c8f5e83 | |
| parent | 0c198035e958a3caa0bd1e0fd9f419bf1308399d (diff) | |
[1.7.x] Adjusted refactoring of vendor checks.
Thanks Shai for the thorough review.
Backport of fb90b7c from master
| -rw-r--r-- | django/db/backends/__init__.py | 7 | ||||
| -rw-r--r-- | django/db/backends/mysql/base.py | 2 | ||||
| -rw-r--r-- | django/db/backends/oracle/base.py | 2 | ||||
| -rw-r--r-- | tests/inspectdb/tests.py | 4 | ||||
| -rw-r--r-- | tests/introspection/tests.py | 3 | ||||
| -rw-r--r-- | tests/serializers_regress/tests.py | 3 |
6 files changed, 11 insertions, 10 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index 1f223ed8a3..3ad1440bda 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -616,8 +616,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? @@ -679,6 +677,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 @@ -737,7 +738,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 diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 3c71c5792c..9172d7069a 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -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 diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index 312eb7e40b..f945b26101 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -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): diff --git a/tests/inspectdb/tests.py b/tests/inspectdb/tests.py index 856e63ce4a..92a5a02dbd 100644 --- a/tests/inspectdb/tests.py +++ b/tests/inspectdb/tests.py @@ -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) diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py index fe7c3cefba..fee6e59544 100644 --- a/tests/introspection/tests.py +++ b/tests/introspection/tests.py @@ -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'] ) diff --git a/tests/serializers_regress/tests.py b/tests/serializers_regress/tests.py index 5ee2a93a6f..22db69ba13 100644 --- a/tests/serializers_regress/tests.py +++ b/tests/serializers_regress/tests.py @@ -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 |
