2018-11-16 23:25:26 +08:00
|
|
|
import operator
|
|
|
|
|
2019-08-20 15:54:41 +08:00
|
|
|
from django.db import InterfaceError
|
2015-01-13 04:20:40 +08:00
|
|
|
from django.db.backends.base.features import BaseDatabaseFeatures
|
2016-06-23 23:52:14 +08:00
|
|
|
from django.utils.functional import cached_property
|
2015-01-13 04:20:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
class DatabaseFeatures(BaseDatabaseFeatures):
|
2015-03-27 04:54:43 +08:00
|
|
|
allows_group_by_selected_pks = True
|
2019-01-31 04:31:56 +08:00
|
|
|
can_return_columns_from_insert = True
|
|
|
|
can_return_rows_from_bulk_insert = True
|
2015-01-13 04:20:40 +08:00
|
|
|
has_real_datatype = True
|
2015-01-11 02:13:28 +08:00
|
|
|
has_native_uuid_field = True
|
2015-01-13 04:20:40 +08:00
|
|
|
has_native_duration_field = True
|
2019-06-09 08:56:37 +08:00
|
|
|
has_native_json_field = True
|
2015-01-13 04:20:40 +08:00
|
|
|
can_defer_constraint_checks = True
|
|
|
|
has_select_for_update = True
|
|
|
|
has_select_for_update_nowait = True
|
2017-06-30 04:00:15 +08:00
|
|
|
has_select_for_update_of = True
|
2019-02-05 00:07:46 +08:00
|
|
|
has_select_for_update_skip_locked = True
|
2020-05-11 00:25:06 +08:00
|
|
|
has_select_for_no_key_update = True
|
2015-01-13 04:20:40 +08:00
|
|
|
can_release_savepoints = True
|
|
|
|
supports_tablespaces = True
|
|
|
|
supports_transactions = True
|
2018-11-27 02:45:05 +08:00
|
|
|
can_introspect_materialized_views = True
|
2015-01-13 04:20:40 +08:00
|
|
|
can_distinct_on_fields = True
|
|
|
|
can_rollback_ddl = True
|
|
|
|
supports_combined_alters = True
|
|
|
|
nulls_order_largest = True
|
|
|
|
closed_cursor_error_class = InterfaceError
|
|
|
|
has_case_insensitive_like = False
|
2015-05-09 19:55:03 +08:00
|
|
|
greatest_least_ignores_nulls = True
|
2015-09-06 17:12:08 +08:00
|
|
|
can_clone_databases = True
|
2016-01-20 09:43:41 +08:00
|
|
|
supports_temporal_subtraction = True
|
2017-01-14 21:32:07 +08:00
|
|
|
supports_slicing_ordering_in_compound = True
|
2017-08-09 04:13:02 +08:00
|
|
|
create_test_procedure_without_params_sql = """
|
|
|
|
CREATE FUNCTION test_procedure () RETURNS void AS $$
|
|
|
|
DECLARE
|
|
|
|
V_I INTEGER;
|
|
|
|
BEGIN
|
|
|
|
V_I := 1;
|
|
|
|
END;
|
|
|
|
$$ LANGUAGE plpgsql;"""
|
|
|
|
create_test_procedure_with_int_param_sql = """
|
|
|
|
CREATE FUNCTION test_procedure (P_I INTEGER) RETURNS void AS $$
|
|
|
|
DECLARE
|
|
|
|
V_I INTEGER;
|
|
|
|
BEGIN
|
|
|
|
V_I := P_I;
|
|
|
|
END;
|
|
|
|
$$ LANGUAGE plpgsql;"""
|
2018-09-19 04:14:44 +08:00
|
|
|
requires_casted_case_in_updates = True
|
2017-09-18 21:42:29 +08:00
|
|
|
supports_over_clause = True
|
2020-01-20 07:30:54 +08:00
|
|
|
only_supports_unbounded_with_preceding_and_following = True
|
2017-09-06 22:26:45 +08:00
|
|
|
supports_aggregate_filter_clause = True
|
2017-09-10 22:34:18 +08:00
|
|
|
supported_explain_formats = {'JSON', 'TEXT', 'XML', 'YAML'}
|
|
|
|
validates_explain_options = False # A query will error on invalid options.
|
2018-08-27 10:25:06 +08:00
|
|
|
supports_deferrable_unique_constraints = True
|
2020-05-18 14:12:20 +08:00
|
|
|
has_json_operators = True
|
2020-07-30 12:38:02 +08:00
|
|
|
json_key_contains_list_matching_requires_list = True
|
2021-01-19 19:25:20 +08:00
|
|
|
test_collations = {
|
|
|
|
'non_default': 'sv-x-icu',
|
|
|
|
'swedish_ci': 'sv-x-icu',
|
|
|
|
}
|
2020-10-06 18:51:35 +08:00
|
|
|
|
2020-12-11 01:00:57 +08:00
|
|
|
django_test_skips = {
|
|
|
|
'opclasses are PostgreSQL only.': {
|
|
|
|
'indexes.tests.SchemaIndexesNotPostgreSQLTests.test_create_index_ignores_opclasses',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-05-27 06:25:45 +08:00
|
|
|
@cached_property
|
|
|
|
def introspected_field_types(self):
|
|
|
|
return {
|
|
|
|
**super().introspected_field_types,
|
|
|
|
'PositiveBigIntegerField': 'BigIntegerField',
|
|
|
|
'PositiveIntegerField': 'IntegerField',
|
|
|
|
'PositiveSmallIntegerField': 'SmallIntegerField',
|
|
|
|
}
|
|
|
|
|
2019-12-14 04:10:33 +08:00
|
|
|
@cached_property
|
|
|
|
def is_postgresql_11(self):
|
|
|
|
return self.connection.pg_version >= 110000
|
|
|
|
|
2019-10-22 16:31:41 +08:00
|
|
|
@cached_property
|
|
|
|
def is_postgresql_12(self):
|
|
|
|
return self.connection.pg_version >= 120000
|
|
|
|
|
2020-07-27 05:29:05 +08:00
|
|
|
@cached_property
|
|
|
|
def is_postgresql_13(self):
|
|
|
|
return self.connection.pg_version >= 130000
|
|
|
|
|
2019-12-14 04:10:33 +08:00
|
|
|
has_websearch_to_tsquery = property(operator.attrgetter('is_postgresql_11'))
|
2019-10-31 20:33:53 +08:00
|
|
|
supports_covering_indexes = property(operator.attrgetter('is_postgresql_11'))
|
|
|
|
supports_covering_gist_indexes = property(operator.attrgetter('is_postgresql_12'))
|
2020-07-18 19:17:39 +08:00
|
|
|
supports_non_deterministic_collations = property(operator.attrgetter('is_postgresql_12'))
|