summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2024-03-11 13:24:18 +0100
committerGitHub <noreply@github.com>2024-03-11 13:24:18 +0100
commit3592e9fcb13b1353cfa78f03c2574fe9282ce5ac (patch)
treeffc51cbd5646084f374462195318eefdadc39e65
parentf2c35249591d202ee544eadcaa9de4c255045692 (diff)
Optimized DatabaseOperations.bulk_insert_sql() a bit on Oracle.
-rw-r--r--django/db/backends/oracle/operations.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py
index 4f4658299d..15a1b3335b 100644
--- a/django/db/backends/oracle/operations.py
+++ b/django/db/backends/oracle/operations.py
@@ -669,18 +669,20 @@ END;
return self._get_no_autofield_sequence_name(table) if row is None else row[0]
def bulk_insert_sql(self, fields, placeholder_rows):
+ field_placeholders = [
+ BulkInsertMapper.types.get(
+ getattr(field, "target_field", field).get_internal_type(), "%s"
+ )
+ for field in fields
+ if field
+ ]
query = []
for row in placeholder_rows:
select = []
for i, placeholder in enumerate(row):
# A model without any fields has fields=[None].
if fields[i]:
- internal_type = getattr(
- fields[i], "target_field", fields[i]
- ).get_internal_type()
- placeholder = (
- BulkInsertMapper.types.get(internal_type, "%s") % placeholder
- )
+ placeholder = field_placeholders[i] % placeholder
# Add columns aliases to the first select to avoid "ORA-00918:
# column ambiguously defined" when two or more columns in the
# first select have the same value.