[v2.0.0-beta.5] Transaction suspend on the second request
PNixx opened this issue · comments
Sergey Odintsov commented
amphp/sql-common: v2.0.0-beta.7
amphp/postgres: v2.0.0-beta.5
amphp/sql: v2.0.0-beta.6
Example:
use Amp\Postgres;
use Amp\Postgres\PostgresConfig;
require 'vendor/autoload.php';
$config = new PostgresConfig('localhost', 5432, 'user', 'pass', 'dbtest');
$connection = Postgres\connect($config);
$transaction = $connection->beginTransaction();
$result = $transaction->execute('INSERT INTO customers (email,time_zone) VALUES (:email,:time_zone) RETURNING *', [
'email' => 'test@test.com',
'time_zone' => 'UTC',
]);
print_r($result->fetchRow());
$result = $transaction->execute('INSERT INTO customers (email) VALUES (:email) RETURNING *', [
'email' => 'test2@test.com',
]); // <---- suspend here
print_r($result->fetchRow());
$transaction->rollback();
STDOUT:
Array
(
[email] => test@test.com
[time_zone] => UTC
)
Works correctly if request similar sql queries:
use Amp\Postgres;
use Amp\Postgres\PostgresConfig;
require 'vendor/autoload.php';
$config = new PostgresConfig('localhost', 5432, 'user', 'pass', 'dbtest');
$connection = Postgres\connect($config);
$transaction = $connection->beginTransaction();
$result = $transaction->execute('INSERT INTO customers (email,time_zone) VALUES (:email,:time_zone) RETURNING *', [
'email' => 'test@test.com',
'time_zone' => 'UTC',
]);
print_r($result->fetchRow());
$result = $transaction->execute('INSERT INTO customers (email,time_zone) VALUES (:email,:time_zone) RETURNING *', [
'email' => 'test2@test.com',
'time_zone' => 'UTC',
]);
print_r($result->fetchRow());
$transaction->rollback();
STDOUT:
Array
(
[email] => test@test.com
[time_zone] => UTC
)
Array
(
[email] => test2@test.com
[time_zone] => UTC
)
In v2.0.0-beta.4 works correctly.
Aaron Piotrowski commented
This should be fixed by amphp/sql-common@v2.0.0-beta.8
.