Codeception / Codeception/module-db
inserting null on an autoincrement primary key prevents cleanup
- Ngôn ngữ chính
- PHP
- Star
- 23
- Fork
- 31
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
When I have a table with a primary key column that's also increment, it's valid to set it to `null` on the insert statement. the last insert it will then return the auto increment value, which is the primary key in that case.
As already noticed in #44, the auto increment column doesn't have to be part of the primary key, so the return value of last insert id ironically doesn't necessarily belong to the primary key. However, #44 also broke the case, which one might perceive as more common, that the last insert id may also be the primary key.
So, `haveInDatabase(table, ['id' => null, ...])` with id as autoincrement and pk will lead to the id being set to `null` for cleanup, which results in the row not being removed at teardown.
I have prepared a fix for this case, which hopefully is specific enough to not interfere with other use cases.
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
Bắt đầu bằng cách tái hiện trường hợp haveInDatabase(table, ['id' => null, ...]) với khóa chính autoincrement, sau đó truy vết cách ID đã chèn được ghi lại để teardown cleanup. Hoàn tất có nghĩa là giá trị khóa chính được tạo ra được giữ lại và hàng đã chèn được xóa trong quá trình cleanup, mà không làm hỏng các trường hợp cột autoincrement không phải là khóa chính.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- php
- Lĩnh vực
- databases, testing-qa
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 38/100