@@ -1161,36 +1161,17 @@ def simple_insert_returning_txn(
11611161 SQLite versions that don't support it).
11621162 """
11631163
1164- if txn .database_engine .supports_returning :
1165- sql = "INSERT INTO %s (%s) VALUES(%s) RETURNING %s" % (
1166- table ,
1167- ", " .join (k for k in values .keys ()),
1168- ", " .join ("?" for _ in values .keys ()),
1169- ", " .join (k for k in returning ),
1170- )
1171-
1172- txn .execute (sql , list (values .values ()))
1173- row = txn .fetchone ()
1174- assert row is not None
1175- return row
1176- else :
1177- # For old versions of SQLite we do a standard insert and then can
1178- # use `last_insert_rowid` to get at the row we just inserted
1179- DatabasePool .simple_insert_txn (
1180- txn ,
1181- table = table ,
1182- values = values ,
1183- )
1184- txn .execute ("SELECT last_insert_rowid()" )
1185- row = txn .fetchone ()
1186- assert row is not None
1187- (rowid ,) = row
1164+ sql = "INSERT INTO %s (%s) VALUES(%s) RETURNING %s" % (
1165+ table ,
1166+ ", " .join (k for k in values .keys ()),
1167+ ", " .join ("?" for _ in values .keys ()),
1168+ ", " .join (k for k in returning ),
1169+ )
11881170
1189- row = DatabasePool .simple_select_one_txn (
1190- txn , table = table , keyvalues = {"rowid" : rowid }, retcols = returning
1191- )
1192- assert row is not None
1193- return row
1171+ txn .execute (sql , list (values .values ()))
1172+ row = txn .fetchone ()
1173+ assert row is not None
1174+ return row
11941175
11951176 async def simple_insert_many (
11961177 self ,
0 commit comments