Codeception / Codeception/module-db

haveInDatabase() is not usable inside a transaction on PostgreSQL

Offen
#87 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
PHP
Sterne
23
Forks
31
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.