﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37404	JSONIn with Value(None, JSONField()) does not match JSON null on Oracle	Clifford Gama	Clifford Gama	"On Oracle, `JSONIn.as_oracle()` [https://github.com/django/django/blob/8c34887b1ad8bb3ec61c6e713442dab3c643d557/django/db/models/fields/json.py#L462 only special-cases JSONNull()] on the right-hand side. A `Value(None, output_field=JSONField())` is not routed to the same `JSON_EQUAL` path, so it doesn't match a JSON `null` row in `__in`. Both `JSONNull()` and `Value(None, JSONField())` match in `__exact`.

Failing test:

{{{#!diff
diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py
index 264b88a23d..2276b7857d 100644
--- a/tests/model_fields/test_jsonfield.py
+++ b/tests/model_fields/test_jsonfield.py
@@ -1076,6 +1076,15 @@ def test_in_json_whitespace(self):
                     [obj],
                 )
 
+    @skipUnlessDBFeature(""supports_primitives_in_json_field"")
+    @skipIfDBFeature(""has_native_json_field"")
+    def test_in_value_json_typed_none_matches_json_null(self):
+        json_null = NullableJSONModel.objects.create(value=JSONNull())
+        self.assertSequenceEqual(
+            NullableJSONModel.objects.filter(value__in=[Value(None, JSONField())]),
+            [json_null],
+        )
+
     def test_key_in(self):
         tests = [
             (""value__c__in"", [14], self.objs[3:5]),
}}}

Found while working on #37403, but the bug predates the introduction of JSONIn or JSONNull, so it's not a regression in 6.1."	Bug	assigned	Database layer (models, ORM)	5.2	Normal		json, oracle, null, JSONIn		Accepted	0	0	0	0	0	0
