summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2025-12-23 01:25:56 -0500
committerJacob Walls <jacobtylerwalls@gmail.com>2025-12-31 10:47:20 -0500
commit2ca2afdffdc7a33344f3189965b6ebc92196dc10 (patch)
treea4a23e46f93c2ffa75027203dadd95bb6caa4eae /tests
parent8346657aaff7da999dca32574e6595f8c9543a0c (diff)
[5.2.x] Refs #33647 -- Fixed silent data truncation in bulk_create on Postgres.
Regression in a16eedcf9c69d8a11d94cac1811018c5b996d491. The UNNEST strategy is affected by the same problem bulk_update has wrt/ to silent data truncation due to its usage of db_type which always returns a parametrized subtype. Backport of d6ae2ed868e43671afc4d433c3d8f4d27f7eb555 from main.
Diffstat (limited to 'tests')
-rw-r--r--tests/backends/postgresql/test_compilation.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/backends/postgresql/test_compilation.py b/tests/backends/postgresql/test_compilation.py
index 11c4015e01..2053c18a1a 100644
--- a/tests/backends/postgresql/test_compilation.py
+++ b/tests/backends/postgresql/test_compilation.py
@@ -3,6 +3,7 @@ from datetime import date
from django.db import connection
from django.db.models.expressions import RawSQL
+from django.db.utils import DataError
from django.test import TestCase
from ..models import Article, Reporter, Square
@@ -42,3 +43,12 @@ class BulkCreateUnnestTests(TestCase):
self.assertEqual(
[article.reporter for article in articles], [reporter, reporter]
)
+
+ def test_parametrized_db_type(self):
+ with self.assertRaises(DataError):
+ Reporter.objects.bulk_create(
+ [
+ Reporter(),
+ Reporter(first_name="a" * 31),
+ ]
+ )