diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cdf774c..5fd04358 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ Changed Fixed - `Schema\Grammar::compileAdd()` `Schema\Grammar::compileChange()` `Schema\Grammar::compileChange()` now create separate statements (#159) +# v6.1.2 (2024-01-16) + +Fixed +- Fixed an error when rolling back a transaction that did not execute begin (#166) + # v6.1.1 (2023-12-11) Fixed diff --git a/src/Concerns/ManagesTransactions.php b/src/Concerns/ManagesTransactions.php index 368245a9..a79a602b 100644 --- a/src/Concerns/ManagesTransactions.php +++ b/src/Concerns/ManagesTransactions.php @@ -168,7 +168,7 @@ protected function performRollBack($toLevel) if ($this->currentTransaction !== null) { try { - if ($this->currentTransaction->state() === Transaction::STATE_ACTIVE) { + if ($this->currentTransaction->state() === Transaction::STATE_ACTIVE && $this->currentTransaction->id() !== null) { $this->currentTransaction->rollBack(); } } finally { diff --git a/tests/SessionNotFoundTest.php b/tests/SessionNotFoundTest.php index af2859f6..089993bd 100644 --- a/tests/SessionNotFoundTest.php +++ b/tests/SessionNotFoundTest.php @@ -160,13 +160,13 @@ public function test_session_not_found_on_cursor(): void $passes = 0; $conn->transaction(function () use ($conn, &$passes) { - $cursor = $conn->cursor('SELECT 12345'); - if ($passes === 0) { $this->deleteSession($conn); $passes++; } + $cursor = $conn->cursor('SELECT 12345'); + $this->assertEquals([12345], $cursor->current()); $passes++;