mirror of https://github.com/django/django.git
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
This commit is contained in:
parent
d4677d4bfb
commit
c663e8fbd7
|
@ -313,7 +313,10 @@ class InsertQuery(Query):
|
||||||
|
|
||||||
def execute_sql(self, return_id=False):
|
def execute_sql(self, return_id=False):
|
||||||
cursor = super(InsertQuery, self).execute_sql(None)
|
cursor = super(InsertQuery, self).execute_sql(None)
|
||||||
if return_id and cursor:
|
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,
|
return self.connection.ops.last_insert_id(cursor,
|
||||||
self.model._meta.db_table, self.model._meta.pk.column)
|
self.model._meta.db_table, self.model._meta.pk.column)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue