Opened 3 hours ago

Last modified 100 minutes ago

#36689 assigned Bug

Top-level __in lookup on JSONField fails on MySQL, Oracle

Reported by: Jacob Walls Owned by: Clifford Gama
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: JSON, In
Cc: Clifford Gama Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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 (1)

comment:1 by Clifford Gama, 100 minutes ago

Owner: set to Clifford Gama
Status: newassigned

Thanks for the report!

Note: See TracTickets for help on using tickets.
Back to Top