From 779cd28acb1f7eb06f629c0ea4ded99b5ebb670a Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Fri, 22 Sep 2023 06:01:11 +0200 Subject: Fixed #34840 -- Avoided casting string base fields on PostgreSQL. Thanks Alex Vandiver for the report. Regression in 09ffc5c1212d4ced58b708cbbf3dfbfb77b782ca. --- tests/backends/postgresql/tests.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/backends/postgresql') diff --git a/tests/backends/postgresql/tests.py b/tests/backends/postgresql/tests.py index 31aac022c8..a045195991 100644 --- a/tests/backends/postgresql/tests.py +++ b/tests/backends/postgresql/tests.py @@ -369,6 +369,20 @@ class Tests(TestCase): with self.subTest(lookup=lookup): self.assertIn("::text", do.lookup_cast(lookup)) + def test_lookup_cast_isnull_noop(self): + from django.db.backends.postgresql.operations import DatabaseOperations + + do = DatabaseOperations(connection=None) + # Using __isnull lookup doesn't require casting. + tests = [ + "CharField", + "EmailField", + "TextField", + ] + for field_type in tests: + with self.subTest(field_type=field_type): + self.assertEqual(do.lookup_cast("isnull", field_type), "%s") + def test_correct_extraction_psycopg_version(self): from django.db.backends.postgresql.base import Database, psycopg_version -- cgit v1.3