features.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. from django.db.backends.base.features import BaseDatabaseFeatures
  2. from django.db.utils import InterfaceError as DjangoInterfaceError
  3. from django.utils.functional import cached_property
  4. try:
  5. import pytz
  6. except ImportError:
  7. pytz = None
  8. class DatabaseFeatures(BaseDatabaseFeatures):
  9. uses_custom_query_class = True
  10. has_bulk_insert = True
  11. # DateTimeField doesn't support timezones, only DateTimeOffsetField
  12. supports_timezones = False
  13. supports_sequence_reset = False
  14. can_return_id_from_insert = True
  15. supports_regex_backreferencing = False
  16. supports_tablespaces = True
  17. supports_nullable_unique_constraints = False
  18. supports_partially_nullable_unique_constraints = False
  19. can_introspect_autofield = True
  20. can_introspect_small_integer_field = True
  21. supports_subqueries_in_group_by = False
  22. allow_sliced_subqueries = False
  23. uses_savepoints = True
  24. supports_paramstyle_pyformat = False
  25. closed_cursor_error_class = DjangoInterfaceError
  26. requires_literal_defaults = True
  27. has_native_uuid_field = True
  28. @cached_property
  29. def has_zoneinfo_database(self):
  30. return pytz is not None
  31. # Dict of test import path and list of versions on which it fails
  32. failing_tests = {
  33. # Some tests are known to fail with django-mssql.
  34. 'aggregation.tests.BaseAggregateTestCase.test_decimal_max_digits_has_no_effect': [(1, 8)],
  35. 'aggregation.tests.ComplexAggregateTestCase.test_expression_on_aggregation': [(1, 8)],
  36. # MSSQL throws an arithmetic overflow error.
  37. 'expressions.tests.ExpressionOperatorTests.test_righthand_power': [(1, 8)],
  38. # MSSQL supports more than the long name length of 71 that is asserted
  39. 'invalid_models_tests.tests.FieldNamesTests.test_M2M_long_column_name': [(1, 8)],
  40. # MSSQL doesn't allow changing a field in to an IDENTITY field.
  41. 'schema.tests.SchemaTests.test_alter_int_pk_to_autofield_pk': [(1, 8)],
  42. }