AnswerDotAI / AnswerDotAI/sqlite-minutils
`select last_insert_rowid()` doesn't account for ROLLBACK on transaction
- Langage dominant
- Python
- Étoiles
- 17
- Forks
- 9
- Métriques de merge des PR
- Aucune PR mergée en 30 j
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`
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Aucun fichier du dépôt ni aucun test n’est nommé. Commencez par reproduire la transaction présentée dans l’issue et lisez la documentation de SQLite sur last_insert_rowid ; le travail est terminé lorsqu’un insert annulé n’amène plus la bibliothèque à signaler cette rowid comme dernière clé primaire.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python, sqlite
- Domaine
- database
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 35/100