Codeception / Codeception/module-db
haveInDatabase() is not usable inside a transaction on PostgreSQL
- 主要語言
- PHP
- 星號
- 23
- 分支
- 31
- PR 合併指標
- 30 天內沒有已合併 PR
描述
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.
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
從 haveInDatabase() 進入點開始,在交易中使用 PostgreSQL 時追蹤 lastInsertId() 呼叫。使用名稱不同於 PostgreSQL 產生名稱的主鍵序列重現此情況,然後確認資料庫陳述式成功執行,且不會在未明確告知的情況下中止交易,後續陳述式也不會失敗。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- php, postgresql
- 領域
- database, testing
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100