Codeception / Codeception/module-db
inserting null on an autoincrement primary key prevents cleanup
- Langage dominant
- PHP
- Étoiles
- 23
- Forks
- 31
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Commencez par reproduire le cas haveInDatabase(table, ['id' => null, ...]) avec une clé primaire autoincrémentée, puis suivez la manière dont l’ID inséré est enregistré pour le teardown cleanup. C’est terminé lorsque la valeur de la clé primaire générée est conservée et que la ligne insérée est supprimée pendant le cleanup, sans casser les cas où la colonne autoincrémentée n’est pas la clé primaire.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- php
- Domaine
- databases, testing-qa
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 38/100