Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10034 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c663e8fbd73ad3ad2f4bd1cdb473b77963c2e352 1 parent d4677d4
Malcolm Tredinnick authored

Showing 1 changed file with 6 additions and 3 deletions. Show diff stats Hide diff stats

  1. 9  django/db/models/sql/subqueries.py
9  django/db/models/sql/subqueries.py
@@ -313,9 +313,12 @@ def as_sql(self):
313 313
 
314 314
     def execute_sql(self, return_id=False):
315 315
         cursor = super(InsertQuery, self).execute_sql(None)
316  
-        if return_id and cursor:
317  
-            return self.connection.ops.last_insert_id(cursor,
318  
-                    self.model._meta.db_table, self.model._meta.pk.column)
  316
+        if not (return_id and cursor):
  317
+            return
  318
+        if self.connection.features.can_return_id_from_insert:
  319
+            return cursor.fetchone()[0]
  320
+        return self.connection.ops.last_insert_id(cursor,
  321
+                self.model._meta.db_table, self.model._meta.pk.column)
319 322
 
320 323
     def insert_values(self, insert_values, raw_values=False):
321 324
         """

0 notes on commit c663e8f

Please sign in to comment.
Something went wrong with that request. Please try again.