Skip to content

Commit

Permalink
fix: fixed an error when rolling back a transaction that did not exec…
Browse files Browse the repository at this point in the history
…ute 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
  • Loading branch information
halnique authored Jan 16, 2024
1 parent 4f175f3 commit dd06a26
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/ManagesTransactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions tests/SessionNotFoundTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit dd06a26

Please sign in to comment.