AnswerDotAI / AnswerDotAI/sqlite-minutils
`select last_insert_rowid()` doesn't account for ROLLBACK on transaction
- Dominant language
- Python
- Stars
- 17
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
We probably don't want to use the SQLIte function `last_insert_rowid()` to get the last_pk. Per the docs on [last_insert_rowid](https://www.sqlite.org/c3ref/last_insert_rowid.html), this is expected behavior:
> For the purposes of this routine, an [INSERT](https://www.sqlite.org/lang_insert.html) is considered to be successful even if it is subsequently rolled back.
---
Get last rowid
```sql
SELECT last_insert_rowid();
```
`0`
Now do the transaction and check the row id:
```sql
BEGIN TRANSACTION;
INSERT INTO users (username) VALUES ('puppy');
SELECT last_insert_rowid();
```
`1`
Roll the transaction back and check the table and rowid:
```sql
ROLLBACK;
SELECT last_insert_rowid();
```
`1`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.