Skip to content

Commit

Permalink
Fix: update insert() coroutine for new last insert id return type
Browse files Browse the repository at this point in the history
  • Loading branch information
rudyryk committed Oct 5, 2015
1 parent 510a274 commit 0f421b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions peewee_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,13 @@ def insert(query):
cursor = yield from cursor_with_query(query)

if query.is_insert_returning:
result = yield from cursor.fetchone()
result = (yield from cursor.fetchone())[0]
else:
result = yield from query.database.last_insert_id_async(
cursor, query.model_class)

cursor.release()
if result:
return result[0]
return result


@asyncio.coroutine
Expand Down
4 changes: 2 additions & 2 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ def test():
result = yield from execute(query)
return result

lst_id = self.run_until_complete(test())
self.assertTrue(lst_id is not None)
last_id = self.run_until_complete(test())
self.assertTrue(last_id is not None)

def test_insert_one_row_query(self):
@asyncio.coroutine
Expand Down

0 comments on commit 0f421b9

Please sign in to comment.