AnswerDotAI / AnswerDotAI/sqlite-minutils
`select last_insert_rowid()` doesn't account for ROLLBACK on transaction
- Ngôn ngữ chính
- Python
- Star
- 17
- Fork
- 9
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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`
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Không có tệp repository hay test nào được nêu. Hãy bắt đầu bằng cách tái hiện transaction được nêu trong issue và đọc tài liệu của SQLite về last_insert_rowid; hoàn thành có nghĩa là một insert bị rollback không còn khiến thư viện báo rowid đó là khóa chính cuối cùng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python, sqlite
- Lĩnh vực
- database
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100