From df2c4952df6d93c575fb8a3c853dc9d4c2449f36 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Fri, 7 Feb 2025 16:34:17 -0500 Subject: Fixed #36173 -- Stabilized identity of Concat with an explicit output_field. When Expression.__init__() overrides make use of *args, **kwargs captures their argument values are respectively bound as a tuple and dict instances. These composite values might themselves contain values that require special identity treatments such as Concat(output_field) as it's a Field instance. Refs #30628 which introduced bound Field differentiation but lacked argument captures handling. Thanks erchenstein for the report. --- tests/db_functions/text/test_concat.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/db_functions') diff --git a/tests/db_functions/text/test_concat.py b/tests/db_functions/text/test_concat.py index 6e4cb91d3a..ffcd19fad6 100644 --- a/tests/db_functions/text/test_concat.py +++ b/tests/db_functions/text/test_concat.py @@ -107,3 +107,17 @@ class ConcatTests(TestCase): ctx.captured_queries[0]["sql"].count("::text"), 1 if connection.vendor == "postgresql" else 0, ) + + def test_equal(self): + self.assertEqual( + Concat("foo", "bar", output_field=TextField()), + Concat("foo", "bar", output_field=TextField()), + ) + self.assertNotEqual( + Concat("foo", "bar", output_field=TextField()), + Concat("foo", "bar", output_field=CharField()), + ) + self.assertNotEqual( + Concat("foo", "bar", output_field=TextField()), + Concat("bar", "foo", output_field=TextField()), + ) -- cgit v1.3