in reply to (jeffa) Re: RFC: transactions.pm
in thread RFC: Transactions.pm
I honestly expected there to be no output ... shouldn't a rollback cause all 'inserted' data to be 'undone'?
It seems that your MySQL (table) does not support transactions, or that my module is broken. I haven't been able to try it with a real DB *yet*, and have only used print to see what methods it executes, but everything seems to be in order. Could you please check if transactions work if you use them without this module?
The module does not work the way I expected it to work. I should have tested it with a database.
Update: New version. This one actually works. I have used your code to test it:
use warnings; use Transactions; use DBI; my $dbh = DBI->connect("dbi:SQLite:db.dat"); our $T = $dbh; $dbh->do('delete from foo'); transaction { for (1..10) { my $sth = $dbh->prepare('insert into foo values(?,?,?)'); $sth->execute($_, chr(ord('a')+$_), chr(ord('z')-$_)); rollback if $_ == 5; } }; print map "@$_\n", @{$dbh->selectall_arrayref('select * from foo')}; $dbh->disconnect;
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
|
|---|