features.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import operator
  2. from django.db.backends.base.features import BaseDatabaseFeatures
  3. from django.db.utils import InterfaceError
  4. from django.utils.functional import cached_property
  5. class DatabaseFeatures(BaseDatabaseFeatures):
  6. allows_group_by_selected_pks = True
  7. can_return_columns_from_insert = True
  8. can_return_multiple_columns_from_insert = True
  9. can_return_rows_from_bulk_insert = True
  10. has_real_datatype = True
  11. has_native_uuid_field = True
  12. has_native_duration_field = True
  13. can_defer_constraint_checks = True
  14. has_select_for_update = True
  15. has_select_for_update_nowait = True
  16. has_select_for_update_of = True
  17. has_select_for_update_skip_locked = True
  18. can_release_savepoints = True
  19. supports_tablespaces = True
  20. supports_transactions = True
  21. can_introspect_autofield = True
  22. can_introspect_ip_address_field = True
  23. can_introspect_materialized_views = True
  24. can_introspect_small_integer_field = True
  25. can_distinct_on_fields = True
  26. can_rollback_ddl = True
  27. supports_combined_alters = True
  28. nulls_order_largest = True
  29. closed_cursor_error_class = InterfaceError
  30. has_case_insensitive_like = False
  31. greatest_least_ignores_nulls = True
  32. can_clone_databases = True
  33. supports_temporal_subtraction = True
  34. supports_slicing_ordering_in_compound = True
  35. create_test_procedure_without_params_sql = """
  36. CREATE FUNCTION test_procedure () RETURNS void AS $$
  37. DECLARE
  38. V_I INTEGER;
  39. BEGIN
  40. V_I := 1;
  41. END;
  42. $$ LANGUAGE plpgsql;"""
  43. create_test_procedure_with_int_param_sql = """
  44. CREATE FUNCTION test_procedure (P_I INTEGER) RETURNS void AS $$
  45. DECLARE
  46. V_I INTEGER;
  47. BEGIN
  48. V_I := P_I;
  49. END;
  50. $$ LANGUAGE plpgsql;"""
  51. requires_casted_case_in_updates = True
  52. supports_over_clause = True
  53. supports_aggregate_filter_clause = True
  54. supported_explain_formats = {'JSON', 'TEXT', 'XML', 'YAML'}
  55. validates_explain_options = False # A query will error on invalid options.
  56. @cached_property
  57. def is_postgresql_9_6(self):
  58. return self.connection.pg_version >= 90600
  59. @cached_property
  60. def is_postgresql_10(self):
  61. return self.connection.pg_version >= 100000
  62. has_brin_autosummarize = property(operator.attrgetter('is_postgresql_10'))
  63. has_phraseto_tsquery = property(operator.attrgetter('is_postgresql_9_6'))
  64. supports_table_partitions = property(operator.attrgetter('is_postgresql_10'))