Codeception / Codeception/module-db
inserting null on an autoincrement primary key prevents cleanup
- 主要语言
- PHP
- 星标
- 23
- 派生
- 31
- PR 合并指标
- 30 天内没有已合并 PR
描述
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.
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先使用自增主键复现 haveInDatabase(table, ['id' => null, ...]) 的情况,然后跟踪插入的 ID 是如何为 teardown cleanup 记录的。完成的标准是保留生成的主键值,并在 cleanup 期间删除插入的行,同时不破坏自增列不是主键的情况。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php
- 领域
- databases, testing-qa
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100