10 my $schema = DBICTest->init_schema(auto_savepoint => 1);
12 my $ars = $schema->resultset('Artist');
14 # test two-phase commit and inner transaction rollback from nested transactions
16 $ars->create({ name => 'in_outer_transaction' });
18 $ars->create({ name => 'in_inner_transaction' });
20 ok($ars->search({ name => 'in_inner_transaction' })->first,
21 'commit from inner transaction visible in outer transaction');
24 $ars->create({ name => 'in_inner_transaction_rolling_back' });
25 die 'rolling back inner transaction';
27 } qr/rolling back inner transaction/, 'inner transaction rollback executed';
28 $ars->create({ name => 'in_outer_transaction2' });
31 ok($ars->search({ name => 'in_outer_transaction' })->first,
32 'commit from outer transaction');
33 ok($ars->search({ name => 'in_outer_transaction2' })->first,
34 'second commit from outer transaction');
35 ok($ars->search({ name => 'in_inner_transaction' })->first,
36 'commit from inner transaction');
37 is $ars->search({ name => 'in_inner_transaction_rolling_back' })->first,
39 'rollback from inner transaction';
41 # make sure the side-effects of RT#67581 do not result in data loss
43 warnings_exist { $row = $ars->create ({ name => 'alpha rank', rank => 'abc' }) }
44 [qr/Non-numeric value supplied for column 'rank' despite the numeric datatype/],
45 'proper warning on string insertion into an numeric column'
47 $row->discard_changes;
48 is ($row->rank, 'abc', 'proper rank inserted into database');