summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Kelly <ian.g.kelly@gmail.com>2010-12-01 23:36:56 +0000
committerIan Kelly <ian.g.kelly@gmail.com>2010-12-01 23:36:56 +0000
commit1f68dc4ad4ddc67831c6aa047683a5b53fa33a37 (patch)
treea5466d2d0fa6c9b5af078fc8da2fc5ab8c36b951
parentdceaa82dec9f97ac77754dfdc737852d8171c8a2 (diff)
Fixed #11706: Added an Oracle connection option to disable the use of RETURNING INTO in INSERT statements.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14765 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/db/backends/oracle/base.py7
-rw-r--r--docs/ref/databases.txt17
2 files changed, 23 insertions, 1 deletions
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index 3e8eae4d3f..d0ed6df3e2 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -351,6 +351,8 @@ class DatabaseWrapper(BaseDatabaseWrapper):
self.oracle_version = None
self.features = DatabaseFeatures(self)
+ use_returning_into = self.settings_dict["OPTIONS"].get('use_returning_into', True)
+ self.features.can_return_id_from_insert = use_returning_into
self.ops = DatabaseOperations()
self.client = DatabaseClient(self)
self.creation = DatabaseCreation(self)
@@ -377,7 +379,10 @@ class DatabaseWrapper(BaseDatabaseWrapper):
cursor = None
if not self._valid_connection():
conn_string = convert_unicode(self._connect_string())
- self.connection = Database.connect(conn_string, **self.settings_dict['OPTIONS'])
+ conn_params = self.settings_dict['OPTIONS'].copy()
+ if 'use_returning_into' in conn_params:
+ del conn_params['use_returning_into']
+ self.connection = Database.connect(conn_string, **conn_params)
cursor = FormatStylePlaceholderCursor(self.connection)
# Set oracle date to ansi date format. This only needs to execute
# once when we create a new connection. We also set the Territory
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
index 3aa78ef647..1406b7447e 100644
--- a/docs/ref/databases.txt
+++ b/docs/ref/databases.txt
@@ -585,6 +585,23 @@ your Oracle database configuration to True::
Failure to do this may result in crashes and other odd behavior.
+INSERT ... RETURNING INTO
+-------------------------
+
+By default, the Oracle backend uses a ``RETURNING INTO`` clause to efficiently
+retrieve the value of an ``AutoField`` when inserting new rows. This behavior
+may result in a ``DatabaseError`` in certain unusual setups, such as when
+inserting into a remote table, or into a view with an ``INSTEAD OF`` trigger.
+The ``RETURNING INTO`` clause can be disabled by setting the
+``use_returning_into`` option of the database configuration to False::
+
+ 'OPTIONS': {
+ 'use_returning_into': False,
+ },
+
+In this case, the Oracle backend will use a separate ``SELECT`` query to
+retrieve AutoField values.
+
Tablespace options
------------------