Codeception / Codeception/module-db
haveInDatabase() is not usable inside a transaction on PostgreSQL
- Linguagem predominante
- PHP
- Estrelas
- 23
- Forks
- 31
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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.
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Comece pelo ponto de entrada haveInDatabase() e rastreie a chamada a lastInsertId() quando PostgreSQL for usado dentro de uma transação. Reproduza o caso com uma sequência de chave primária cujo nome seja diferente do nome gerado pelo PostgreSQL e verifique se a instrução do banco de dados é executada com sucesso sem abortar silenciosamente a transação e se as instruções subsequentes não falham.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- php, postgresql
- Domínio
- database, testing
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 42/100