Author: mtredinnick
Date: 2009-03-12 00:31:34 -0500 (Thu, 12 Mar 2009)
New Revision: 10034
Modified:
django/trunk/django/db/models/sql/subqueries.py
Log:
Return last insert ID correctly when the feature is enabled.
This was overlooked when merging the patch from #3460 in r10029.
Thank to Ian Kelly for noticing. Refs #10467.
Modified: django/trunk/django/db/models/sql/subqueries.py
===================================================================
--- django/trunk/django/db/models/sql/subqueries.py 2009-03-12 05:30:51 UTC
(rev 10033)
+++ django/trunk/django/db/models/sql/subqueries.py 2009-03-12 05:31:34 UTC
(rev 10034)
@@ -313,9 +313,12 @@
def execute_sql(self, return_id=False):
cursor = super(InsertQuery, self).execute_sql(None)
- if return_id and cursor:
- return self.connection.ops.last_insert_id(cursor,
- self.model._meta.db_table, self.model._meta.pk.column)
+ if not (return_id and cursor):
+ return
+ if self.connection.features.can_return_id_from_insert:
+ return cursor.fetchone()[0]
+ return self.connection.ops.last_insert_id(cursor,
+ self.model._meta.db_table, self.model._meta.pk.column)
def insert_values(self, insert_values, raw_values=False):
"""
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---