diff options
| author | Simon Charette <charette.s@gmail.com> | 2025-12-23 01:25:56 -0500 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-12-31 10:41:55 -0500 |
| commit | d6ae2ed868e43671afc4d433c3d8f4d27f7eb555 (patch) | |
| tree | 4c363c5e644138f3efa61d810c8e0506b243ec9c /tests/backends | |
| parent | 79ab0993d0f2253e10ea638bcefc98ec2d890a47 (diff) | |
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.
Diffstat (limited to 'tests/backends')
| -rw-r--r-- | tests/backends/postgresql/test_compilation.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/backends/postgresql/test_compilation.py b/tests/backends/postgresql/test_compilation.py index 275660607d..a922df3956 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 @@ -48,3 +49,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), + ] + ) |
