2020-07-18 19:17:39 +08:00
|
|
|
from django.db import DatabaseError, InterfaceError
|
2015-01-13 04:20:40 +08:00
|
|
|
from django.db.backends.base.features import BaseDatabaseFeatures
|
2020-05-27 06:25:45 +08:00
|
|
|
from django.utils.functional import cached_property
|
2015-01-13 04:20:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
class DatabaseFeatures(BaseDatabaseFeatures):
|
2020-09-08 03:45:56 +08:00
|
|
|
# Oracle crashes with "ORA-00932: inconsistent datatypes: expected - got
|
|
|
|
# BLOB" when grouping by LOBs (#24096).
|
|
|
|
allows_group_by_lob = False
|
2015-01-13 04:20:40 +08:00
|
|
|
interprets_empty_strings_as_nulls = True
|
|
|
|
has_select_for_update = True
|
|
|
|
has_select_for_update_nowait = True
|
2016-06-23 23:52:14 +08:00
|
|
|
has_select_for_update_skip_locked = True
|
2017-06-30 04:00:15 +08:00
|
|
|
has_select_for_update_of = True
|
|
|
|
select_for_update_of_column = True
|
2019-01-31 04:31:56 +08:00
|
|
|
can_return_columns_from_insert = True
|
2015-01-13 04:20:40 +08:00
|
|
|
supports_subqueries_in_group_by = False
|
|
|
|
supports_transactions = True
|
|
|
|
supports_timezones = False
|
|
|
|
has_native_duration_field = True
|
|
|
|
can_defer_constraint_checks = True
|
|
|
|
supports_partially_nullable_unique_constraints = False
|
2018-08-27 10:25:06 +08:00
|
|
|
supports_deferrable_unique_constraints = True
|
2015-01-13 04:20:40 +08:00
|
|
|
truncates_names = True
|
|
|
|
supports_tablespaces = True
|
|
|
|
supports_sequence_reset = False
|
2018-11-27 02:45:05 +08:00
|
|
|
can_introspect_materialized_views = True
|
2015-01-13 04:20:40 +08:00
|
|
|
atomic_transactions = False
|
|
|
|
supports_combined_alters = False
|
|
|
|
nulls_order_largest = True
|
|
|
|
requires_literal_defaults = True
|
|
|
|
closed_cursor_error_class = InterfaceError
|
|
|
|
bare_select_suffix = " FROM DUAL"
|
|
|
|
# select for update with limit can be achieved on Oracle, but not with the current backend.
|
|
|
|
supports_select_for_update_with_limit = False
|
2016-01-20 09:43:41 +08:00
|
|
|
supports_temporal_subtraction = True
|
2016-06-21 12:01:03 +08:00
|
|
|
# Oracle doesn't ignore quoted identifiers case but the current backend
|
|
|
|
# does by uppercasing all identifiers.
|
2016-11-29 02:29:21 +08:00
|
|
|
ignores_table_name_case = True
|
2017-05-23 23:02:40 +08:00
|
|
|
supports_index_on_text_field = False
|
2017-07-25 03:51:29 +08:00
|
|
|
has_case_insensitive_like = False
|
2017-08-09 04:13:02 +08:00
|
|
|
create_test_procedure_without_params_sql = """
|
|
|
|
CREATE PROCEDURE "TEST_PROCEDURE" AS
|
|
|
|
V_I INTEGER;
|
|
|
|
BEGIN
|
|
|
|
V_I := 1;
|
|
|
|
END;
|
|
|
|
"""
|
|
|
|
create_test_procedure_with_int_param_sql = """
|
|
|
|
CREATE PROCEDURE "TEST_PROCEDURE" (P_I INTEGER) AS
|
|
|
|
V_I INTEGER;
|
|
|
|
BEGIN
|
|
|
|
V_I := P_I;
|
|
|
|
END;
|
|
|
|
"""
|
2017-08-13 03:06:49 +08:00
|
|
|
supports_callproc_kwargs = True
|
2017-09-18 21:42:29 +08:00
|
|
|
supports_over_clause = True
|
2019-01-16 12:23:50 +08:00
|
|
|
supports_frame_range_fixed_distance = True
|
2017-10-03 07:35:38 +08:00
|
|
|
supports_ignore_conflicts = False
|
2017-10-06 00:52:37 +08:00
|
|
|
max_query_params = 2**16 - 1
|
2018-09-13 15:34:02 +08:00
|
|
|
supports_partial_indexes = False
|
2019-02-07 02:25:04 +08:00
|
|
|
supports_slicing_ordering_in_compound = True
|
2019-02-11 22:17:06 +08:00
|
|
|
allows_multiple_constraints_on_same_fields = False
|
2019-08-11 14:12:11 +08:00
|
|
|
supports_boolean_expr_in_select_clause = False
|
2019-06-09 08:56:37 +08:00
|
|
|
supports_primitives_in_json_field = False
|
2020-07-28 19:06:52 +08:00
|
|
|
supports_json_field_contains = False
|
2020-07-18 19:17:39 +08:00
|
|
|
supports_collation_on_textfield = False
|
2020-08-08 19:37:06 +08:00
|
|
|
test_collations = {
|
|
|
|
'ci': 'BINARY_CI',
|
|
|
|
'cs': 'BINARY',
|
2020-07-18 19:17:39 +08:00
|
|
|
'non_default': 'SWEDISH_CI',
|
2020-08-08 19:37:06 +08:00
|
|
|
'swedish_ci': 'SWEDISH_CI',
|
|
|
|
}
|
2020-05-27 06:25:45 +08:00
|
|
|
|
2020-12-11 01:00:57 +08:00
|
|
|
django_test_skips = {
|
|
|
|
"Oracle doesn't support SHA224.": {
|
|
|
|
'db_functions.text.test_sha224.SHA224Tests.test_basic',
|
|
|
|
'db_functions.text.test_sha224.SHA224Tests.test_transform',
|
|
|
|
},
|
|
|
|
"Oracle doesn't support bitwise XOR.": {
|
|
|
|
'expressions.tests.ExpressionOperatorTests.test_lefthand_bitwise_xor',
|
|
|
|
'expressions.tests.ExpressionOperatorTests.test_lefthand_bitwise_xor_null',
|
|
|
|
},
|
|
|
|
"Oracle requires ORDER BY in row_number, ANSI:SQL doesn't.": {
|
|
|
|
'expressions_window.tests.WindowFunctionTests.test_row_number_no_ordering',
|
|
|
|
},
|
|
|
|
'Raises ORA-00600: internal error code on Oracle 18.': {
|
|
|
|
'model_fields.test_jsonfield.TestQuerying.test_usage_in_subquery',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
django_test_expected_failures = {
|
|
|
|
# A bug in Django/cx_Oracle with respect to string handling (#23843).
|
|
|
|
'annotations.tests.NonAggregateAnnotationTestCase.test_custom_functions',
|
|
|
|
'annotations.tests.NonAggregateAnnotationTestCase.test_custom_functions_can_ref_other_functions',
|
|
|
|
}
|
|
|
|
|
2020-05-27 06:25:45 +08:00
|
|
|
@cached_property
|
|
|
|
def introspected_field_types(self):
|
|
|
|
return {
|
|
|
|
**super().introspected_field_types,
|
|
|
|
'GenericIPAddressField': 'CharField',
|
|
|
|
'PositiveBigIntegerField': 'BigIntegerField',
|
|
|
|
'PositiveIntegerField': 'IntegerField',
|
|
|
|
'PositiveSmallIntegerField': 'IntegerField',
|
|
|
|
'SmallIntegerField': 'IntegerField',
|
|
|
|
'TimeField': 'DateTimeField',
|
|
|
|
}
|
2020-07-18 19:17:39 +08:00
|
|
|
|
|
|
|
@cached_property
|
|
|
|
def supports_collation_on_charfield(self):
|
|
|
|
with self.connection.cursor() as cursor:
|
|
|
|
try:
|
|
|
|
cursor.execute("SELECT CAST('a' AS VARCHAR2(4001)) FROM dual")
|
|
|
|
except DatabaseError as e:
|
|
|
|
if e.args[0].code == 910:
|
|
|
|
return False
|
|
|
|
raise
|
|
|
|
return True
|
2020-11-08 15:52:34 +08:00
|
|
|
|
|
|
|
@cached_property
|
|
|
|
def has_json_object_function(self):
|
|
|
|
# Oracle < 18 supports JSON_OBJECT() but it's not fully functional.
|
|
|
|
return self.connection.oracle_version >= (18,)
|