From 9fe050a27598cdce7f2ef7a332b4818b493a8702 Mon Sep 17 00:00:00 2001 From: Ramiro Morales Date: Sun, 11 Sep 2011 23:02:53 +0000 Subject: [PATCH] Added an implementation of bulk insert via the ORM to the Oracle DB backend. Refs #7596, r16739 and http://troels.arvin.dk/db/rdbms/#insert-multiple git-svn-id: http://code.djangoproject.com/svn/django/trunk@16819 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/backends/oracle/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index 3cadb6617da..bd45f9bd3d1 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -78,6 +78,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): supports_bitwise_or = False can_defer_constraint_checks = True ignores_nulls_in_unique_constraints = False + has_bulk_insert = True class DatabaseOperations(BaseDatabaseOperations): compiler_module = "django.db.backends.oracle.compiler" @@ -372,6 +373,10 @@ WHEN (new.%(col_name)s IS NULL) name_length = self.max_name_length() - 3 return '%s_TR' % util.truncate_name(table, name_length).upper() + def bulk_insert_sql(self, fields, num_values): + items_sql = "SELECT %s FROM DUAL" % ", ".join(["%s"] * len(fields)) + return " UNION ALL ".join([items_sql] * num_values) + class _UninitializedOperatorsDescriptor(object):