Commit e3bc11cc authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

[1.7.x] Replaced vendor checks by three feature flags.

Backport of c70a61eb from master
parent 7f48d44c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -575,6 +575,7 @@ class BaseDatabaseFeatures(object):
    can_return_id_from_insert = False
    has_bulk_insert = False
    uses_savepoints = False
    can_release_savepoints = True
    can_combine_inserts_with_and_without_auto_increment_pk = False

    # If True, don't use integer foreign keys referring to, e.g., positive
@@ -610,6 +611,8 @@ class BaseDatabaseFeatures(object):
    supports_subqueries_in_group_by = True
    supports_bitwise_or = True

    supports_binary_field = True

    # Do time/datetime fields have microsecond precision?
    supports_microsecond_precision = True

@@ -703,6 +706,9 @@ class BaseDatabaseFeatures(object):
    # statements before executing them?
    requires_sqlparse_for_splitting = True

    # Suffix for backends that don't support "SELECT xxx;" queries.
    bare_select_suffix = ''

    def __init__(self, connection):
        self.connection = connection

+2 −0
Original line number Diff line number Diff line
@@ -172,6 +172,8 @@ class DatabaseFeatures(BaseDatabaseFeatures):
    has_select_for_update_nowait = False
    supports_forward_references = False
    supports_long_model_names = 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
+2 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
    needs_datetime_string_cast = False
    interprets_empty_strings_as_nulls = True
    uses_savepoints = True
    can_release_savepoints = False
    has_select_for_update = True
    has_select_for_update_nowait = True
    can_return_id_from_insert = True
@@ -116,6 +117,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
    requires_literal_defaults = True
    connection_persists_old_columns = True
    closed_cursor_error_class = InterfaceError
    bare_select_suffix = " FROM DUAL"


class DatabaseOperations(BaseDatabaseOperations):
+2 −4
Original line number Diff line number Diff line
@@ -3939,8 +3939,7 @@ class UserAdminTest(TestCase):
        ContentType.objects.clear_cache()

        expected_queries = 10
        # Oracle doesn't implement "RELEASE SAVPOINT", see #20387.
        if connection.vendor == 'oracle':
        if not connection.features.can_release_savepoints:
            expected_queries -= 1

        with self.assertNumQueries(expected_queries):
@@ -3982,8 +3981,7 @@ class GroupAdminTest(TestCase):
        g = Group.objects.create(name="test_group")

        expected_queries = 8
        # Oracle doesn't implement "RELEASE SAVPOINT", see #20387.
        if connection.vendor == 'oracle':
        if not connection.features.can_release_savepoints:
            expected_queries -= 1

        with self.assertNumQueries(expected_queries):
+1 −4
Original line number Diff line number Diff line
@@ -131,7 +131,6 @@ class SQLiteTests(TestCase):
            self.assertRaises(NotImplementedError,
                models.Item.objects.all().aggregate, aggregate('last_modified'))


    def test_convert_values_to_handle_null_value(self):
        convert_values = DatabaseOperations(connection).convert_values
        self.assertIsNone(convert_values(None, AutoField(primary_key=True)))
@@ -464,9 +463,7 @@ class EscapingChecks(TestCase):
    EscapingChecksDebug test case, to also test CursorDebugWrapper.
    """

    # For Oracle, when you want to select a value, you need to specify the
    # special pseudo-table 'dual'; a select with no from clause is invalid.
    bare_select_suffix = " FROM DUAL" if connection.vendor == 'oracle' else ""
    bare_select_suffix = connection.features.bare_select_suffix

    def test_paramless_no_escaping(self):
        cursor = connection.cursor()
Loading