Development of an internal social media platform with personalised dashboards for students
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 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. from django.db.backends.base.features import BaseDatabaseFeatures
  2. from django.utils.functional import cached_property
  3. class DatabaseFeatures(BaseDatabaseFeatures):
  4. empty_fetchmany_value = ()
  5. update_can_self_select = False
  6. allows_group_by_pk = True
  7. related_fields_match_type = True
  8. # MySQL doesn't support sliced subqueries with IN/ALL/ANY/SOME.
  9. allow_sliced_subqueries_with_in = False
  10. has_select_for_update = True
  11. supports_forward_references = False
  12. supports_regex_backreferencing = False
  13. supports_date_lookup_using_string = False
  14. can_introspect_autofield = True
  15. can_introspect_binary_field = False
  16. can_introspect_small_integer_field = True
  17. can_introspect_positive_integer_field = True
  18. introspected_boolean_field_type = 'IntegerField'
  19. supports_index_column_ordering = False
  20. supports_timezones = False
  21. requires_explicit_null_ordering_when_grouping = True
  22. allows_auto_pk_0 = False
  23. uses_savepoints = True
  24. can_release_savepoints = True
  25. atomic_transactions = False
  26. supports_column_check_constraints = False
  27. can_clone_databases = True
  28. supports_temporal_subtraction = True
  29. supports_select_intersection = False
  30. supports_select_difference = False
  31. supports_slicing_ordering_in_compound = True
  32. supports_index_on_text_field = False
  33. has_case_insensitive_like = False
  34. create_test_procedure_without_params_sql = """
  35. CREATE PROCEDURE test_procedure ()
  36. BEGIN
  37. DECLARE V_I INTEGER;
  38. SET V_I = 1;
  39. END;
  40. """
  41. create_test_procedure_with_int_param_sql = """
  42. CREATE PROCEDURE test_procedure (P_I INTEGER)
  43. BEGIN
  44. DECLARE V_I INTEGER;
  45. SET V_I = P_I;
  46. END;
  47. """
  48. db_functions_convert_bytes_to_str = True
  49. # Alias MySQL's TRADITIONAL to TEXT for consistency with other backends.
  50. supported_explain_formats = {'JSON', 'TEXT', 'TRADITIONAL'}
  51. @cached_property
  52. def _mysql_storage_engine(self):
  53. "Internal method used in Django tests. Don't rely on this from your code"
  54. with self.connection.cursor() as cursor:
  55. cursor.execute("SELECT ENGINE FROM INFORMATION_SCHEMA.ENGINES WHERE SUPPORT = 'DEFAULT'")
  56. result = cursor.fetchone()
  57. return result[0]
  58. @cached_property
  59. def can_introspect_foreign_keys(self):
  60. "Confirm support for introspected foreign keys"
  61. return self._mysql_storage_engine != 'MyISAM'
  62. @cached_property
  63. def has_zoneinfo_database(self):
  64. # Test if the time zone definitions are installed.
  65. with self.connection.cursor() as cursor:
  66. cursor.execute("SELECT 1 FROM mysql.time_zone LIMIT 1")
  67. return cursor.fetchone() is not None
  68. @cached_property
  69. def is_sql_auto_is_null_enabled(self):
  70. with self.connection.cursor() as cursor:
  71. cursor.execute('SELECT @@SQL_AUTO_IS_NULL')
  72. result = cursor.fetchone()
  73. return result and result[0] == 1
  74. @cached_property
  75. def supports_over_clause(self):
  76. return self.connection.mysql_version >= (8, 0, 2)
  77. @cached_property
  78. def has_select_for_update_skip_locked(self):
  79. return self.connection.mysql_version >= (8, 0, 1)
  80. has_select_for_update_nowait = has_select_for_update_skip_locked
  81. @cached_property
  82. def needs_explain_extended(self):
  83. # EXTENDED is deprecated (and not required) in 5.7 and removed in 8.0.
  84. return self.connection.mysql_version < (5, 7)
  85. @cached_property
  86. def supports_transactions(self):
  87. """
  88. All storage engines except MyISAM support transactions.
  89. """
  90. return self._mysql_storage_engine != 'MyISAM'
  91. @cached_property
  92. def ignores_table_name_case(self):
  93. with self.connection.cursor() as cursor:
  94. cursor.execute('SELECT @@LOWER_CASE_TABLE_NAMES')
  95. result = cursor.fetchone()
  96. return result and result[0] != 0