-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fixed an error when rolling back a transaction that did not execute begin #166
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The processing order of the Before the change, the test code would fail due to this effect.
The reason why 1. |
||
|
||
$this->assertEquals([12345], $cursor->current()); | ||
|
||
$passes++; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When rolling back a transaction, an exception is now thrown if the target transactionId is not specified.
ref: https://github.com/googleapis/google-cloud-php/pull/6708/files#diff-25ee9adab31aa54b734a2bc5f254b0e922b13e1c0ad27f1fff60a9a534552a03
L192-L194
This caused the following tests to fail.
Originally, when a transaction was called without specifying any options,
Operation::beginTransaction()
was called internally to set the transactionId.With this change, the default options specified have been changed and
Operation::beginTransaction()
is no longer called internally.ref: https://github.com/googleapis/google-cloud-php/pull/6708/files#diff-25ee9adab31aa54b734a2bc5f254b0e922b13e1c0ad27f1fff60a9a534552a03
L495-L497
As a result,
InvalidArgumentException('Rollback failed: Transaction not initiated.')
exception is thrown when rollback is done without calling any query inDatabase::runTransaction()
.