an optional tuple indicating the minimum supported database version oracle can t group by lob large object data types does the backend support selfreference subqueries in the delete statement does the backend distinguish between and none does the backend allow inserting duplicate null rows in a nullable unique field all core backends implement this correctly but other databases such as sql server do not does the backend allow inserting duplicate rows when a uniquetogether constraint exists and some fields are nullable but not all of them does the backend supports specifying whether null values should be considered distinct in unique constraints does the backend support initially deferrable unique constraints if true don t use integer foreign keys referring to e g positive integer primary keys does the database s select for update of syntax require a column rather than a table does the default test database allow multiple connections usually an indication that the test database is inmemory can an object be saved without an explicit primary key can a fixture contain forward references i e are fk constraints checked at the end of transaction or at the end of each save operation does the backend truncate names properly when they are too long is there a real datatype in addition to floatsdoubles does the backend ignore unnecessary order by clauses in subqueries is there a true datatype for uuid is there a true datatype for timedeltas does the database driver supports same type temporal data subtraction by returning the type used to store duration field does the regex lookup support backreferencing and grouping can datedatetime lookups be performed using a string can datetimes with timezones be used does the database have a copy of the zoneinfo database when performing a group by is an order by null required to remove any ordering does the backend order null values as largest or smallest does the backend support nulls first and nulls last in order by does the backend orders nulls first by default the database s limit on the number of query parameters can an object have an autoincrement primary key of 0 do we need to null a foreignkey out or can the constraint check be deferred does the backend support tablespaces default to false because it isn t in the sql standard does the backend reset sequences between tests can the backend introspect the default value of a column confirm support for introspected foreign keys every database can do this reliably except mysql which can t do it for myisam tables map fields which some backends may not be able to differentiate to the field it s introspected as can the backend introspect the column order ascdesc for indexes does the backend support introspection of materialized views support for the distinct on clause does the backend prevent running sql queries in broken transactions can we roll back ddl in a transaction can we issue more than one alter column clause in an alter table does it support foreign keys can it create foreign key constraints inline when adding columns can an index be renamed does it automatically index foreign keys does it support check constraints does the backend support introspection of check constraints does the backend support pyformat style names name value parameter passing note this can be provided by the backend even if not supported by the python driver does the backend require literal defaults rather than parameterized ones does the backend support functions in defaults does the backend support the default keyword in insert queries does the backend support the default keyword in bulk insert queries does the backend require a connection reset after each material schema change what kind of error does the backend throw when accessing closed cursor does a like a match suffix for backends that don t support select xxx queries if null is implied on columns without needing to be explicitly specified does the backend support select for update queries with limit and offset does the backend ignore null expressions in greatest and least queries unless every expression is null can the backend clone databases for parallel test execution defaults to false to allow thirdparty backends to optin does the backend consider table names with different casing to be equal place for update right after from clause used on mssql combinatorial flags does the database support sql 2003 filter where in aggregate expressions does the backend support indexing a textfield does the backend support window expressions expression over does the backend support cast with precision how many second decimals does the database return when casting a value to a type with time sql to create a procedure for use by the django test suite the functionality of the procedure isn t important sql to create a table with a composite primary key for use by the django test suite does the backend support keyword parameters for cursor callproc what formats does the backend explain syntax support does the backend support the default parameter in lead and lag does the backend support ignoring constraint or uniqueness errors during insert does the backend support updating rows on constraint or uniqueness errors during insert does this backend require casting the results of case expressions used in update statements to ensure the expression has the correct type does the backend support partial indexes create index where does the backend support covering indexes create index include does the backend support indexes on expressions does the backend treat collate as an indexed expression does the database allow more than one constraint or index on the same fields does the backend support boolean expressions in select and group by clauses does the backend support comparing boolean expressions in where clauses eg where price 0 is not null does the backend support jsonfield can the backend introspect a jsonfield does the backend support primitives in jsonfield is there a true datatype for json does the backend use postgresqlstyle json operators like does the backend support contains and containedby lookups for a jsonfield does valuedcontains f g without a list around the dict match d f g does the backend support jsonobject database function does the backend support column collations does the backend support nondeterministic collations does the backend support column and table comments does the backend support column comments in add column statements does the backend support stored generated columns does the backend support virtual generated columns does the backend support the logical xor operator set to exception message if null characters in text are disallowed does the backend support unlimited character columns collation names for use by the django test suite sql template override for tests aggregation tests nowutc sql to create a model instance using the database defaults a set of dotted paths to tests in django s test suite that are expected to fail on this database a map of reasons to sets of dotted paths to tests in django s test suite that should be skipped for this database does this backend support explaining query execution return self connection ops explainprefix is not none cachedproperty def supportstransactionsself an optional tuple indicating the minimum supported database version oracle can t group by lob large object data types does the backend support self reference subqueries in the delete statement does the backend distinguish between and none does the backend allow inserting duplicate null rows in a nullable unique field all core backends implement this correctly but other databases such as sql server do not does the backend allow inserting duplicate rows when a unique_together constraint exists and some fields are nullable but not all of them does the backend supports specifying whether null values should be considered distinct in unique constraints does the backend support initially deferrable unique constraints if true don t use integer foreign keys referring to e g positive integer primary keys does the database s select for update of syntax require a column rather than a table does the default test database allow multiple connections usually an indication that the test database is in memory can an object be saved without an explicit primary key can a fixture contain forward references i e are fk constraints checked at the end of transaction or at the end of each save operation does the backend truncate names properly when they are too long is there a real datatype in addition to floats doubles does the backend ignore unnecessary order by clauses in subqueries is there a true datatype for uuid is there a true datatype for timedeltas does the database driver supports same type temporal data subtraction by returning the type used to store duration field does the __regex lookup support backreferencing and grouping can date datetime lookups be performed using a string can datetimes with timezones be used does the database have a copy of the zoneinfo database when performing a group by is an order by null required to remove any ordering does the backend order null values as largest or smallest does the backend support nulls first and nulls last in order by does the backend orders nulls first by default the database s limit on the number of query parameters can an object have an autoincrement primary key of 0 do we need to null a foreignkey out or can the constraint check be deferred does the backend support tablespaces default to false because it isn t in the sql standard does the backend reset sequences between tests can the backend introspect the default value of a column confirm support for introspected foreign keys every database can do this reliably except mysql which can t do it for myisam tables map fields which some backends may not be able to differentiate to the field it s introspected as can the backend introspect the column order asc desc for indexes does the backend support introspection of materialized views support for the distinct on clause does the backend prevent running sql queries in broken transactions can we roll back ddl in a transaction can we issue more than one alter column clause in an alter table does it support foreign keys can it create foreign key constraints inline when adding columns can an index be renamed does it automatically index foreign keys does it support check constraints does the backend support introspection of check constraints does the backend support pyformat style name s name value parameter passing note this can be provided by the backend even if not supported by the python driver does the backend require literal defaults rather than parameterized ones does the backend support functions in defaults does the backend support the default keyword in insert queries does the backend support the default keyword in bulk insert queries does the backend require a connection reset after each material schema change what kind of error does the backend throw when accessing closed cursor does a like a match suffix for backends that don t support select xxx queries if null is implied on columns without needing to be explicitly specified does the backend support select for update queries with limit and offset does the backend ignore null expressions in greatest and least queries unless every expression is null can the backend clone databases for parallel test execution defaults to false to allow third party backends to opt in does the backend consider table names with different casing to be equal place for update right after from clause used on mssql combinatorial flags does the database support sql 2003 filter where in aggregate expressions does the backend support indexing a textfield does the backend support window expressions expression over does the backend support cast with precision how many second decimals does the database return when casting a value to a type with time sql to create a procedure for use by the django test suite the functionality of the procedure isn t important sql to create a table with a composite primary key for use by the django test suite does the backend support keyword parameters for cursor callproc what formats does the backend explain syntax support does the backend support the default parameter in lead and lag does the backend support ignoring constraint or uniqueness errors during insert does the backend support updating rows on constraint or uniqueness errors during insert does this backend require casting the results of case expressions used in update statements to ensure the expression has the correct type does the backend support partial indexes create index where does the backend support covering indexes create index include does the backend support indexes on expressions does the backend treat collate as an indexed expression does the database allow more than one constraint or index on the same field s does the backend support boolean expressions in select and group by clauses does the backend support comparing boolean expressions in where clauses eg where price 0 is not null does the backend support jsonfield can the backend introspect a jsonfield does the backend support primitives in jsonfield is there a true datatype for json does the backend use postgresql style json operators like does the backend support __contains and __contained_by lookups for a jsonfield does value__d__contains f g without a list around the dict match d f g does the backend support jsonobject database function does the backend support column collations does the backend support non deterministic collations does the backend support column and table comments does the backend support column comments in add column statements does the backend support stored generated columns does the backend support virtual generated columns does the backend support the logical xor operator set to exception message if null characters in text are disallowed does the backend support unlimited character columns collation names for use by the django test suite case insensitive case sensitive non default swedish case insensitive a collation that can be used for virtual columns sql template override for tests aggregation tests nowutc sql to create a model instance using the database defaults a set of dotted paths to tests in django s test suite that are expected to fail on this database a map of reasons to sets of dotted paths to tests in django s test suite that should be skipped for this database does this backend support explaining query execution confirm support for transactions
from django.db import ProgrammingError
from django.utils.functional import cached_property


class BaseDatabaseFeatures:
    
    minimum_database_version = None
    gis_enabled = False
    
    allows_group_by_lob = True
    allows_group_by_selected_pks = False
    allows_group_by_select_index = True
    empty_fetchmany_value = []
    update_can_self_select = True
    
    
    delete_can_self_reference_subquery = True

    
    interprets_empty_strings_as_nulls = False

    
    
    
    supports_nullable_unique_constraints = True

    
    
    supports_partially_nullable_unique_constraints = True

    
    
    supports_nulls_distinct_unique_constraints = False

    
    supports_deferrable_unique_constraints = False

    can_use_chunked_reads = True
    can_return_columns_from_insert = False
    can_return_rows_from_bulk_insert = False
    has_bulk_insert = True
    uses_savepoints = True
    can_release_savepoints = False

    
    
    related_fields_match_type = False
    allow_sliced_subqueries_with_in = True
    has_select_for_update = False
    has_select_for_update_nowait = False
    has_select_for_update_skip_locked = False
    has_select_for_update_of = False
    has_select_for_no_key_update = False
    
    
    select_for_update_of_column = False

    
    
    test_db_allows_multiple_connections = True

    
    supports_unspecified_pk = False

    
    
    
    supports_forward_references = True

    
    truncates_names = False

    
    has_real_datatype = False
    supports_subqueries_in_group_by = True

    
    ignores_unnecessary_order_by_in_subqueries = True

    
    has_native_uuid_field = False

    
    has_native_duration_field = False

    
    
    supports_temporal_subtraction = False

    
    supports_regex_backreferencing = True

    
    supports_date_lookup_using_string = True

    
    supports_timezones = True

    
    has_zoneinfo_database = True

    
    
    requires_explicit_null_ordering_when_grouping = False

    
    nulls_order_largest = False

    
    supports_order_by_nulls_modifier = True

    
    order_by_nulls_first = False

    
    max_query_params = None

    
    allows_auto_pk_0 = True

    
    
    can_defer_constraint_checks = False

    
    
    supports_tablespaces = False

    
    supports_sequence_reset = True

    
    can_introspect_default = True

    
    
    
    can_introspect_foreign_keys = True

    
    
    introspected_field_types = {
        "AutoField": "AutoField",
        "BigAutoField": "BigAutoField",
        "BigIntegerField": "BigIntegerField",
        "BinaryField": "BinaryField",
        "BooleanField": "BooleanField",
        "CharField": "CharField",
        "DurationField": "DurationField",
        "GenericIPAddressField": "GenericIPAddressField",
        "IntegerField": "IntegerField",
        "PositiveBigIntegerField": "PositiveBigIntegerField",
        "PositiveIntegerField": "PositiveIntegerField",
        "PositiveSmallIntegerField": "PositiveSmallIntegerField",
        "SmallAutoField": "SmallAutoField",
        "SmallIntegerField": "SmallIntegerField",
        "TimeField": "TimeField",
    }

    
    supports_index_column_ordering = True

    
    can_introspect_materialized_views = False

    
    can_distinct_on_fields = False

    
    atomic_transactions = True

    
    can_rollback_ddl = False

    schema_editor_uses_clientside_param_binding = False

    
    supports_combined_alters = False

    
    supports_foreign_keys = True

    
    can_create_inline_fk = True

    
    can_rename_index = False

    
    indexes_foreign_keys = True

    
    supports_column_check_constraints = True
    supports_table_check_constraints = True
    
    can_introspect_check_constraints = True

    
    
    
    supports_paramstyle_pyformat = True

    
    requires_literal_defaults = False

    
    supports_expression_defaults = True

    
    supports_default_keyword_in_insert = True

    
    supports_default_keyword_in_bulk_insert = True

    
    connection_persists_old_columns = False

    
    closed_cursor_error_class = ProgrammingError

    
    has_case_insensitive_like = False

    
    bare_select_suffix = ""

    
    implied_column_null = False

    
    supports_select_for_update_with_limit = True

    
    
    greatest_least_ignores_nulls = False

    
    
    can_clone_databases = False

    
    
    ignores_table_name_case = False

    
    for_update_after_from = False

    
    supports_select_union = True
    supports_select_intersection = True
    supports_select_difference = True
    supports_slicing_ordering_in_compound = False
    supports_parentheses_in_compound = True
    requires_compound_order_by_subquery = False

    
    
    supports_aggregate_filter_clause = False

    
    supports_index_on_text_field = True

    
    supports_over_clause = False
    supports_frame_range_fixed_distance = False
    supports_frame_exclusion = False
    only_supports_unbounded_with_preceding_and_following = False

    
    supports_cast_with_precision = True

    
    
    time_cast_precision = 6

    
    
    create_test_procedure_without_params_sql = None
    create_test_procedure_with_int_param_sql = None

    
    
    create_test_table_with_composite_primary_key = None

    
    supports_callproc_kwargs = False

    
    supported_explain_formats = set()

    
    supports_default_in_lead_lag = True

    
    
    supports_ignore_conflicts = True
    
    
    supports_update_conflicts = False
    supports_update_conflicts_with_target = False

    
    
    requires_casted_case_in_updates = False

    
    supports_partial_indexes = True
    supports_functions_in_partial_indexes = True
    
    supports_covering_indexes = False
    
    supports_expression_indexes = True
    
    collate_as_index_expression = False

    
    
    allows_multiple_constraints_on_same_fields = True

    
    
    supports_boolean_expr_in_select_clause = True
    
    
    supports_comparing_boolean_expr = True

    
    supports_json_field = True
    
    can_introspect_json_field = True
    
    supports_primitives_in_json_field = True
    
    has_native_json_field = False
    
    has_json_operators = False
    
    
    supports_json_field_contains = True
    
    
    json_key_contains_list_matching_requires_list = False
    
    has_json_object_function = True

    
    supports_collation_on_charfield = True
    supports_collation_on_textfield = True
    
    supports_non_deterministic_collations = True

    
    supports_comments = False
    
    supports_comments_inline = False

    
    supports_stored_generated_columns = False
    
    supports_virtual_generated_columns = False

    
    supports_logical_xor = False

    
    prohibits_null_characters_in_text_exception = None

    
    supports_unlimited_charfield = False

    
    test_collations = {
        "ci": None,  
        "cs": None,  
        "non_default": None,  
        "swedish_ci": None,  
        "virtual": None,  
    }
    
    test_now_utc_template = None

    
    insert_test_table_with_defaults = None

    
    
    django_test_expected_failures = set()
    
    
    django_test_skips = {}

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

    @cached_property
    def supports_explaining_query_execution(self):
        
        return self.connection.ops.explain_prefix is not None

    @cached_property
    def supports_transactions(self):
        
        with self.connection.cursor() as cursor:
            cursor.execute("CREATE TABLE ROLLBACK_TEST (X INT)")
            self.connection.set_autocommit(False)
            cursor.execute("INSERT INTO ROLLBACK_TEST (X) VALUES (8)")
            self.connection.rollback()
            self.connection.set_autocommit(True)
            cursor.execute("SELECT COUNT(X) FROM ROLLBACK_TEST")
            (count,) = cursor.fetchone()
            cursor.execute("DROP TABLE ROLLBACK_TEST")
        return count == 0

    def allows_group_by_selected_pks_on_model(self, model):
        if not self.allows_group_by_selected_pks:
            return False
        return model._meta.managed