mirror of
https://github.com/django/django.git
synced 2025-03-13 10:50:55 +00:00
Optimized DatabaseOperations.bulk_insert_sql() a bit on Oracle.
This commit is contained in:
parent
f2c3524959
commit
3592e9fcb1
@ -669,18 +669,20 @@ END;
|
|||||||
return self._get_no_autofield_sequence_name(table) if row is None else row[0]
|
return self._get_no_autofield_sequence_name(table) if row is None else row[0]
|
||||||
|
|
||||||
def bulk_insert_sql(self, fields, placeholder_rows):
|
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 = []
|
query = []
|
||||||
for row in placeholder_rows:
|
for row in placeholder_rows:
|
||||||
select = []
|
select = []
|
||||||
for i, placeholder in enumerate(row):
|
for i, placeholder in enumerate(row):
|
||||||
# A model without any fields has fields=[None].
|
# A model without any fields has fields=[None].
|
||||||
if fields[i]:
|
if fields[i]:
|
||||||
internal_type = getattr(
|
placeholder = field_placeholders[i] % placeholder
|
||||||
fields[i], "target_field", fields[i]
|
|
||||||
).get_internal_type()
|
|
||||||
placeholder = (
|
|
||||||
BulkInsertMapper.types.get(internal_type, "%s") % placeholder
|
|
||||||
)
|
|
||||||
# Add columns aliases to the first select to avoid "ORA-00918:
|
# Add columns aliases to the first select to avoid "ORA-00918:
|
||||||
# column ambiguously defined" when two or more columns in the
|
# column ambiguously defined" when two or more columns in the
|
||||||
# first select have the same value.
|
# first select have the same value.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user