(self, fields, placeholder_rows)
| 667 | return self._get_no_autofield_sequence_name(table) if row is None else row[0] |
| 668 | |
| 669 | def bulk_insert_sql(self, fields, placeholder_rows): |
| 670 | field_placeholders = [ |
| 671 | BulkInsertMapper.types.get( |
| 672 | getattr(field, "target_field", field).get_internal_type(), "%s" |
| 673 | ) |
| 674 | for field in fields |
| 675 | if field |
| 676 | ] |
| 677 | query = [] |
| 678 | for row in placeholder_rows: |
| 679 | select = [] |
| 680 | for i, placeholder in enumerate(row): |
| 681 | # A model without any fields has fields=[None]. |
| 682 | if fields[i]: |
| 683 | placeholder = field_placeholders[i] % placeholder |
| 684 | # Add columns aliases to the first select to avoid "ORA-00918: |
| 685 | # column ambiguously defined" when two or more columns in the |
| 686 | # first select have the same value. |
| 687 | if not query: |
| 688 | placeholder = "%s col_%s" % (placeholder, i) |
| 689 | select.append(placeholder) |
| 690 | suffix = self.connection.features.bare_select_suffix |
| 691 | query.append(f"SELECT %s{suffix}" % ", ".join(select)) |
| 692 | # Bulk insert to tables with Oracle identity columns causes Oracle to |
| 693 | # add sequence.nextval to it. Sequence.nextval cannot be used with the |
| 694 | # UNION operator. To prevent incorrect SQL, move UNION to a subquery. |
| 695 | return "SELECT * FROM (%s)" % " UNION ALL ".join(query) |
| 696 | |
| 697 | def subtract_temporals(self, internal_type, lhs, rhs): |
| 698 | if internal_type == "DateField": |
no test coverage detected