Skip to content

Commit dd06a26

Browse files
authored
fix: fixed an error when rolling back a transaction that did not execute begin (#166)
* fix: fixed an error when rolling back a transaction that did not execute begin * test: fix cursor rollback * chore: update CHANGELOG * chore: fill release date
1 parent 4f175f3 commit dd06a26

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ Changed
1212
Fixed
1313
- `Schema\Grammar::compileAdd()` `Schema\Grammar::compileChange()` `Schema\Grammar::compileChange()` now create separate statements (#159)
1414

15+
# v6.1.2 (2024-01-16)
16+
17+
Fixed
18+
- Fixed an error when rolling back a transaction that did not execute begin (#166)
19+
1520
# v6.1.1 (2023-12-11)
1621

1722
Fixed

src/Concerns/ManagesTransactions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ protected function performRollBack($toLevel)
168168

169169
if ($this->currentTransaction !== null) {
170170
try {
171-
if ($this->currentTransaction->state() === Transaction::STATE_ACTIVE) {
171+
if ($this->currentTransaction->state() === Transaction::STATE_ACTIVE && $this->currentTransaction->id() !== null) {
172172
$this->currentTransaction->rollBack();
173173
}
174174
} finally {

tests/SessionNotFoundTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,13 @@ public function test_session_not_found_on_cursor(): void
160160
$passes = 0;
161161

162162
$conn->transaction(function () use ($conn, &$passes) {
163-
$cursor = $conn->cursor('SELECT 12345');
164-
165163
if ($passes === 0) {
166164
$this->deleteSession($conn);
167165
$passes++;
168166
}
169167

168+
$cursor = $conn->cursor('SELECT 12345');
169+
170170
$this->assertEquals([12345], $cursor->current());
171171

172172
$passes++;

0 commit comments

Comments
 (0)