Codeception / Codeception/module-db
inserting null on an autoincrement primary key prevents cleanup
- Linguagem predominante
- PHP
- Estrelas
- 23
- Forks
- 31
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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.
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Comece reproduzindo o caso haveInDatabase(table, ['id' => null, ...]) com uma chave primária autoincremental e, em seguida, rastreie como o ID inserido é registrado para o teardown cleanup. O trabalho estará concluído quando o valor da chave primária gerada for mantido e a linha inserida for removida durante o cleanup, sem quebrar os casos em que a coluna autoincremental não é a chave primária.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- php
- Domínio
- databases, testing-qa
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 38/100