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`
贡献指南
这个仓库没有索引到贡献指南
调研方向
没有指定 repository 文件或测试。首先复现 issue 中所示的 transaction,并阅读 SQLite 关于 last_insert_rowid 的文档;完成的标准是,回滚的 insert 不再导致库将该 rowid 报告为最后一个主键。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python, sqlite
- 领域
- database
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100