You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

features.py 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_id_from_insert = True
  8. can_return_ids_from_bulk_insert = True
  9. has_real_datatype = True
  10. has_native_uuid_field = True
  11. has_native_duration_field = True
  12. can_defer_constraint_checks = True
  13. has_select_for_update = True
  14. has_select_for_update_nowait = True
  15. has_select_for_update_of = True
  16. can_release_savepoints = True
  17. supports_tablespaces = True
  18. supports_transactions = True
  19. can_introspect_autofield = True
  20. can_introspect_ip_address_field = True
  21. can_introspect_materialized_views = True
  22. can_introspect_small_integer_field = True
  23. can_distinct_on_fields = True
  24. can_rollback_ddl = True
  25. supports_combined_alters = True
  26. nulls_order_largest = True
  27. closed_cursor_error_class = InterfaceError
  28. has_case_insensitive_like = False
  29. greatest_least_ignores_nulls = True
  30. can_clone_databases = True
  31. supports_temporal_subtraction = True
  32. supports_slicing_ordering_in_compound = True
  33. create_test_procedure_without_params_sql = """
  34. CREATE FUNCTION test_procedure () RETURNS void AS $$
  35. DECLARE
  36. V_I INTEGER;
  37. BEGIN
  38. V_I := 1;
  39. END;
  40. $$ LANGUAGE plpgsql;"""
  41. create_test_procedure_with_int_param_sql = """
  42. CREATE FUNCTION test_procedure (P_I INTEGER) RETURNS void AS $$
  43. DECLARE
  44. V_I INTEGER;
  45. BEGIN
  46. V_I := P_I;
  47. END;
  48. $$ LANGUAGE plpgsql;"""
  49. requires_casted_case_in_updates = True
  50. supports_over_clause = True
  51. supports_aggregate_filter_clause = True
  52. supported_explain_formats = {'JSON', 'TEXT', 'XML', 'YAML'}
  53. validates_explain_options = False # A query will error on invalid options.
  54. @cached_property
  55. def is_postgresql_9_5(self):
  56. return self.connection.pg_version >= 90500
  57. @cached_property
  58. def is_postgresql_9_6(self):
  59. return self.connection.pg_version >= 90600
  60. @cached_property
  61. def is_postgresql_10(self):
  62. return self.connection.pg_version >= 100000
  63. has_select_for_update_skip_locked = property(operator.attrgetter('is_postgresql_9_5'))
  64. has_brin_index_support = property(operator.attrgetter('is_postgresql_9_5'))
  65. has_jsonb_agg = property(operator.attrgetter('is_postgresql_9_5'))
  66. has_brin_autosummarize = property(operator.attrgetter('is_postgresql_10'))
  67. has_gin_pending_list_limit = property(operator.attrgetter('is_postgresql_9_5'))
  68. supports_ignore_conflicts = property(operator.attrgetter('is_postgresql_9_5'))
  69. has_phraseto_tsquery = property(operator.attrgetter('is_postgresql_9_6'))
  70. supports_table_partitions = property(operator.attrgetter('is_postgresql_10'))