Top-level __in lookup on JSONField fails on MySQL, Oracle
This test for test_jsonfield.TestQuerying passes on SQLite, Postgres, and MariaDB.
def test_in(self):
self.assertSequenceEqual(
NullableJSONModel.objects.filter(value__in=[{}]),
[self.objs[2]],
)
Fails on MySQL and Oracle. Clifford suspects the specialization in KeyTransformIn is missing in the top-level In lookup.
Failure on MySQL:
======================================================================
FAIL: test_in (model_fields.test_jsonfield.TestQuerying.test_in)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/source/tests/model_fields/test_jsonfield.py", line 379, in test_in
self.assertSequenceEqual(
AssertionError: Sequences differ: <QuerySet []> != [<NullableJSONModel: NullableJSONModel object (3)>]
Second sequence contains 1 additional elements.
First extra element 0:
<NullableJSONModel: NullableJSONModel object (3)>
- <QuerySet []>
+ [<NullableJSONModel: NullableJSONModel object (3)>]
----------------------------------------------------------------------
(0.001) SELECT `model_fields_nullablejsonmodel`.`id`,
`model_fields_nullablejsonmodel`.`value`,
`model_fields_nullablejsonmodel`.`value_custom`
FROM `model_fields_nullablejsonmodel`
WHERE `model_fields_nullablejsonmodel`.`value` IN ('{}'); args=('{}',); alias=default
----------------------------------------------------------------------
Failure on Oracle:
django.db.utils.DatabaseError: ORA-22848: cannot use NCLOB type as comparison key
Help: https://docs.oracle.com/error-help/db/ora-22848/
----------------------------------------------------------------------
(0.016) SELECT "MODEL_FIELDS_NULLABLEJSONMODEL"."ID",
"MODEL_FIELDS_NULLABLEJSONMODEL"."VALUE",
"MODEL_FIELDS_NULLABLEJSONMODEL"."VALUE_CUSTOM"
FROM "MODEL_FIELDS_NULLABLEJSONMODEL"
WHERE "MODEL_FIELDS_NULLABLEJSONMODEL"."VALUE" IN ({}); args=('{}',); alias=default
----------------------------------------------------------------------
Change History
(13)
| Owner: |
set to Clifford Gama
|
| Status: |
new → assigned
|
| Triage Stage: |
Unreviewed → Accepted
|
| Patch needs improvement: |
set
|
| Patch needs improvement: |
unset
|
| Cc: |
Sage Abdullah added
|
| Patch needs improvement: |
set
|
| Patch needs improvement: |
unset
|
| Patch needs improvement: |
set
|
| Patch needs improvement: |
unset
|
| Triage Stage: |
Accepted → Ready for checkin
|
| Resolution: |
→ fixed
|
| Status: |
assigned → closed
|
Thanks for the report!