Closed 0rir closed 4 years ago
That will work. The driver doesn't do any fiddling at the moment with transactions.
That said, I recommend DBIish::Transaction for Pg. Even if you don't do anything advanced, it guarantees the database gets a ROLLBACK when things go wrong on the Raku side.
In the Pg Connect object there appear to be stubs for commit and rollback, but not begin; so no surprise that DBDish::Pg is not handling transactions like P5 DBI did.
My question is does the driver need to handle transactions? More concretely will this approach to transactions work:
use v6.c; use DBIish;
shell 'createdb hell';
my $dbh = DBIish.connect( 'Pg', :database, :AutoCommit(False), :RaiseError(True) );
$dbh.do( 'begin');
$dbh.do( 'create table h (id integer)');
$dbh.do( 'rollback');
$dbh.do( 'begin');
$dbh.do( 'create table h (id integer)');
$dbh.do( 'commit');
$dbh.dispose;
exit;