Skip to content

Nested transaction: begin()+rollback() with nested transaction() does not rollback #469

@krasa

Description

@krasa

begin(), commit() & rollback() calls are forbidden in transaction() callback, but the other way should be forbidden also, or supported - rollback() currently does not work silently.

relates to: #387

example:

$dibi = new Dibi\Connection([
  'driver' => 'postgre',
//  ...
]);

echo "<h2>Before</h2>\n";
$dibi->query('SELECT * FROM [products]')->dump();

$dibi->begin();

$dibi->transaction(function ($transaction) use ($dibi) {
  $dibi->query('INSERT INTO [products]', [
    'title' => 'Test product',
  ]);
});

$dibi->rollback();

echo "<h2>After rollback</h2>\n";
$dibi->query('SELECT * FROM [products]')->dump();
// -> rollback did not work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions