AnswerDotAI / AnswerDotAI/sqlite-minutils
`select last_insert_rowid()` doesn't account for ROLLBACK on transaction
- Lingua principale
- Python
- Stelle
- 17
- Fork
- 9
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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`
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Non viene indicato alcun file del repository né alcun test. Inizia riproducendo la transazione mostrata nell’issue e leggi la documentazione di SQLite su last_insert_rowid; il lavoro è completato quando un insert sottoposto a rollback non fa più sì che la libreria segnali quella rowid come ultima chiave primaria.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python, sqlite
- Ambito
- database
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100