Codeception / Codeception/module-db

haveInDatabase() is not usable inside a transaction on PostgreSQL

未关闭
#87 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
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

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。