diff options
| author | Simon Charette <charette.s@gmail.com> | 2025-01-17 13:41:22 -0500 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-01-20 14:15:32 +0100 |
| commit | 22fc151bb86a553d84c62d7effd289356e9b6c6c (patch) | |
| tree | 1c3e3de407b882885b79090f7fec5ebe0ef08c4a /django/db | |
| parent | f5772de69679efb54129ac1cbca3579b512778af (diff) | |
Fixed #36107 -- Adjusted UNNEST bulk_create strategy to opt-out sized arrays.
The array fields opt-out heuristic failed to account for sized arrays.
Note that we keep relying on db_type as opposed to performing an ArrayField
instance check against the column's field as there could be other
implementations of model fields that use Postgres arrays to store the
optimization must be disabled for all of them.
Refs #35936.
Thanks Claude Paroz for the report and test.
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/backends/postgresql/compiler.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/django/db/backends/postgresql/compiler.py b/django/db/backends/postgresql/compiler.py index 2394d90f55..3b972b5ba5 100644 --- a/django/db/backends/postgresql/compiler.py +++ b/django/db/backends/postgresql/compiler.py @@ -43,7 +43,7 @@ class SQLInsertCompiler(BaseSQLInsertCompiler): db_types = [field.db_type(self.connection) for field in fields] # Abort if any of the fields are arrays as UNNEST indiscriminately # flatten them instead of reducing their nesting by one. - if any(db_type.endswith("[]") for db_type in db_types): + if any(db_type.endswith("]") for db_type in db_types): return super().assemble_as_sql(fields, value_rows) return InsertUnnest(["(%%s)::%s[]" % db_type for db_type in db_types]), [ list(map(list, zip(*value_rows))) |
