summaryrefslogtreecommitdiff
path: root/django/db/backends/mysql/features.py
diff options
context:
space:
mode:
authorsage <laymonage@gmail.com>2019-06-09 07:56:37 +0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-05-08 07:23:31 +0200
commit6789ded0a6ab797f0dcdfa6ad5d1cfa46e23abcd (patch)
tree1de598fc92480c64835b60b6ddbb461c3cd2e864 /django/db/backends/mysql/features.py
parentf97f71f59249f1fbeebe84d4fc858d70fc456f7d (diff)
Fixed #12990, Refs #27694 -- Added JSONField model field.
Thanks to Adam Johnson, Carlton Gibson, Mariusz Felisiak, and Raphael Michel for mentoring this Google Summer of Code 2019 project and everyone else who helped with the patch. Special thanks to Mads Jensen, Nick Pope, and Simon Charette for extensive reviews. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'django/db/backends/mysql/features.py')
-rw-r--r--django/db/backends/mysql/features.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/django/db/backends/mysql/features.py b/django/db/backends/mysql/features.py
index 8a2a64c5e4..faa84f7d7c 100644
--- a/django/db/backends/mysql/features.py
+++ b/django/db/backends/mysql/features.py
@@ -160,3 +160,15 @@ class DatabaseFeatures(BaseDatabaseFeatures):
def supports_default_in_lead_lag(self):
# To be added in https://jira.mariadb.org/browse/MDEV-12981.
return not self.connection.mysql_is_mariadb
+
+ @cached_property
+ def supports_json_field(self):
+ if self.connection.mysql_is_mariadb:
+ return self.connection.mysql_version >= (10, 2, 7)
+ return self.connection.mysql_version >= (5, 7, 8)
+
+ @cached_property
+ def can_introspect_json_field(self):
+ if self.connection.mysql_is_mariadb:
+ return self.supports_json_field and self.can_introspect_check_constraints
+ return self.supports_json_field