Codeception / Codeception/module-db

inserting null on an autoincrement primary key prevents cleanup

オープン
#58 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
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, ...]) のケースを再現し、その後、teardown cleanup のために挿入された ID がどのように記録されるかを追跡します。生成された主キーの値が保持され、cleanup 中に挿入された行が削除され、かつ autoincrement 列が主キーではないケースを壊さないことを確認できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
php
領域
databases, testing-qa
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。