haveInDatabase() is not usable inside a transaction on PostgreSQL

オープン
#87 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

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

調査の方向性

haveInDatabase() のエントリーポイントから開始し、トランザクション内で PostgreSQL を使用した場合の lastInsertId() の呼び出しを追跡します。名前が PostgreSQL の生成した名前と異なる主キーシーケンスを使ってケースを再現し、データベースステートメントがトランザクションを暗黙的に中断せずに成功すること、および後続のステートメントが失敗しないことを確認します。

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

説明

Our tables have PK sequences with different names than the ones postgres generates automatically. Because of that the lastInsertId() call inside haveInDatabase() generates a silent error.
When you use the method in a transaction, you don't see the actual error but the transaction is marked as "aborted" and you get exception and test fail on the next db statement. Without a transaction the test works fine but leaves other residues, which I hoped to clear by rollback. It took some time to debug and find the actual cause.

I did not find any warning about such limitation or previous mentions of it.

As a workaround I used INSERT .. RETURNING.

主要言語
PHP
スター
23
フォーク
31
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Codeception/module-db のほかの issue

Codeception/module-db の issue をすべて見る

似ている issue

PHP の issue をもっと見る

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

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