Fixed #34840 -- Avoided casting string base fields on PostgreSQL.

Thanks Alex Vandiver for the report.

Regression in 09ffc5c121.
This commit is contained in:
Mariusz Felisiak 2023-09-22 06:01:11 +02:00 committed by GitHub
parent 78b5c90753
commit 779cd28acb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 12 deletions

View file

@ -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