Skip to content

Commit

Permalink
Fixes #353, many thanks to @justinrosenthal for reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed May 14, 2014
1 parent 0f8de17 commit 3015ca1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions peewee.py
Original file line number Diff line number Diff line change
Expand Up @@ -2532,13 +2532,17 @@ def last_insert_id(self, cursor, model):
schema = ''
if meta.schema:
schema = '%s.' % meta.schema
result = None
if seq:
cursor.execute("SELECT CURRVAL('%s\"%s\"')" % (schema, seq))
return cursor.fetchone()[0]
result = cursor.fetchone()[0]
elif meta.auto_increment:
cursor.execute("SELECT CURRVAL('%s\"%s_%s_seq\"')" % (
schema, meta.db_table, meta.primary_key.db_column))
return cursor.fetchone()[0]
result = cursor.fetchone()[0]
if self.get_autocommit():
self.get_conn().commit()

This comment has been minimized.

Copy link
@justinrosenthal

justinrosenthal May 14, 2014

Do you know if there's a side effect of calling commit() on a connection that's not in a transaction? In this case, if the primary_key is not a sequence or auto_incrementing, that'll happen.

This comment has been minimized.

Copy link
@coleifer

coleifer May 14, 2014

Author Owner

Yeah, I fixed that in a subsequent commit.

This comment has been minimized.

Copy link
@justinrosenthal

justinrosenthal May 14, 2014

Sorry, just saw that. Thanks for the quick fix and the great library. 👍

return result

def get_indexes_for_table(self, table):
res = self.execute_sql("""
Expand Down
2 changes: 1 addition & 1 deletion playhouse/tests_sqlite_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def assertResults(term, col_idx, expected):
# Use helpers.
query = (MultiColumn
.select(
MultiColumn.c4,
MultiColumn.c4,
MultiColumn.bm25(MultiColumn.c1).alias('score'))
.where(MultiColumn.match('aaaaa'))
.order_by(SQL('score').desc()))
Expand Down

0 comments on commit 3015ca1

Please sign in to comment.