summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql/compiler.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/backends/postgresql/compiler.py')
-rw-r--r--django/db/backends/postgresql/compiler.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/backends/postgresql/compiler.py b/django/db/backends/postgresql/compiler.py
index 38b61c4898..fcd7faaf35 100644
--- a/django/db/backends/postgresql/compiler.py
+++ b/django/db/backends/postgresql/compiler.py
@@ -62,7 +62,9 @@ class SQLInsertCompiler(BaseSQLInsertCompiler):
or any(any(hasattr(value, "as_sql") for value in row) for row in value_rows)
):
return super().assemble_as_sql(fields, value_rows)
- db_types = [field.db_type(self.connection) for field in fields]
+ # Manually remove parameters from `db_type` to ensure no data
+ # truncation takes place (e.g. varchar[] instead of varchar(50)[]).
+ db_types = [field.db_type(self.connection).split("(")[0] for field in fields]
return InsertUnnest(["(%%s)::%s[]" % db_type for db_type in db_types]), [
list(map(list, zip(*value_rows)))
]