1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #35295 -- Used INSERT with multiple rows on Oracle 23c.

This commit is contained in:
Mariusz Felisiak 2024-03-11 10:21:26 +01:00
parent 912f72a6f0
commit 175b04942a
2 changed files with 22 additions and 0 deletions

View File

@ -178,6 +178,10 @@ class DatabaseFeatures(BaseDatabaseFeatures):
def supports_aggregation_over_interval_types(self):
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"

View File

@ -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 = []