AnswerDotAI / AnswerDotAI/sqlite-minutils
`select last_insert_rowid()` doesn't account for ROLLBACK on transaction
- 主要言語
- Python
- スター
- 17
- フォーク
- 9
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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`
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
リポジトリのファイルもテストも指定されていません。まず、issue に示されているトランザクションを再現し、SQLite の last_insert_rowid のドキュメントを読んでください。ロールバックされた insert によって、ライブラリがその rowid を最後の主キーとして報告しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python, sqlite
- 領域
- database
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100