Does not fully support `JSON` because Django has some hard code for `mysql` in `JSONField`
wd0517 opened this issue · 0 comments
wd0517 commented
TiDB Version
v7.2.0
Django Version
v4.1.7
Steps to reproduce
There are some test cases failed to run when I test django-tidb in TiDB v7.2.0.
- model_fields.test_jsonfield.TestQuerying.test_key_quoted_string
- model_fields.test_jsonfield.TestQuerying.test_deep_lookup_mixed
- model_fields.test_jsonfield.TestQuerying.test_deep_lookup_objs
- model_fields.test_jsonfield.TestQuerying.test_icontains
- model_fields.test_jsonfield.TestQuerying.test_key_endswith
- model_fields.test_jsonfield.TestQuerying.test_key_icontains
- model_fields.test_jsonfield.TestQuerying.test_key_iendswith
- model_fields.test_jsonfield.TestQuerying.test_key_iexact
- model_fields.test_jsonfield.TestQuerying.test_key_in
- model_fields.test_jsonfield.TestQuerying.test_key_iregex
- model_fields.test_jsonfield.TestQuerying.test_shallow_obj_lookup
Additional comments
Enable supports_json_field
in featrues.py
is not enough to make JSONField work.
https://github.com/pingcap/django-tidb/blob/main/django_tidb/features.py#L453-L457
The reason of failure is that Django have so much hard code for mysql
, like
- https://github.com/django/django/blob/stable/4.2.x/django/db/models/fields/json.py#L331
- https://github.com/django/django/blob/stable/4.2.x/django/db/models/fields/json.py#L318
- ....
Maybe we should create a new JSONField that is customised for TiDB, or just reverse the verdor name to mysql
?