summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2024-03-11 10:21:26 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2024-03-14 11:11:15 +0100
commit175b04942afaff978013db61495f3b39ea12989b (patch)
treef677e71cef9cc24be0be669e93d55be64ab44a91
parent912f72a6f057bb39f63d66c7fcf0eab7bf28c7b5 (diff)
Fixed #35295 -- Used INSERT with multiple rows on Oracle 23c.
-rw-r--r--django/db/backends/oracle/features.py4
-rw-r--r--django/db/backends/oracle/operations.py18
2 files changed, 22 insertions, 0 deletions
diff --git a/django/db/backends/oracle/features.py b/django/db/backends/oracle/features.py
index 47bdf37efa..4d7ca7dd1f 100644
--- a/django/db/backends/oracle/features.py
+++ b/django/db/backends/oracle/features.py
@@ -179,5 +179,9 @@ class DatabaseFeatures(BaseDatabaseFeatures):
return self.connection.oracle_version >= (23,)
@cached_property
+ def supports_bulk_insert_with_multiple_rows(self):
+ return self.connection.oracle_version >= (23,)
+
+ @cached_property
def bare_select_suffix(self):
return "" if self.connection.oracle_version >= (23,) else " FROM DUAL"
diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py
index 15a1b3335b..15edb292b8 100644
--- a/django/db/backends/oracle/operations.py
+++ b/django/db/backends/oracle/operations.py
@@ -676,6 +676,24 @@ END;
for field in fields
if field
]
+ if (
+ self.connection.features.supports_bulk_insert_with_multiple_rows
+ # A workaround with UNION of SELECTs is required for models without
+ # any fields.
+ and field_placeholders
+ ):
+ placeholder_rows_sql = []
+ for row in placeholder_rows:
+ placeholders_row = (
+ field_placeholder % placeholder
+ for field_placeholder, placeholder in zip(
+ field_placeholders, row, strict=True
+ )
+ )
+ placeholder_rows_sql.append(placeholders_row)
+ return super().bulk_insert_sql(fields, placeholder_rows_sql)
+ # Oracle < 23c doesn't support inserting multiple rows in a single
+ # statement, use UNION of SELECTs as a workaround.
query = []
for row in placeholder_rows:
select = []