14 my $schema = DBICTest->init_schema(auto_savepoint => 1);
16 my $ars = $schema->resultset('Artist');
18 # test two-phase commit and inner transaction rollback from nested transactions
20 $ars->create({ name => 'in_outer_transaction' });
22 $ars->create({ name => 'in_inner_transaction' });
24 ok($ars->search({ name => 'in_inner_transaction' })->first,
25 'commit from inner transaction visible in outer transaction');
28 $ars->create({ name => 'in_inner_transaction_rolling_back' });
29 die 'rolling back inner transaction';
31 } qr/rolling back inner transaction/, 'inner transaction rollback executed';
32 $ars->create({ name => 'in_outer_transaction2' });
35 ok($ars->search({ name => 'in_outer_transaction' })->first,
36 'commit from outer transaction');
37 ok($ars->search({ name => 'in_outer_transaction2' })->first,
38 'second commit from outer transaction');
39 ok($ars->search({ name => 'in_inner_transaction' })->first,
40 'commit from inner transaction');
41 is $ars->search({ name => 'in_inner_transaction_rolling_back' })->first,
43 'rollback from inner transaction';
46 my $schema = DBICTest->init_schema();
48 # make sure the side-effects of RT#67581 do not result in data loss
50 warnings_exist { $row = $schema->resultset('Artist')->create ({ name => 'alpha rank', rank => 'abc' }) }
51 [qr/Non-numeric value supplied for column 'rank' despite the numeric datatype/],
52 'proper warning on string insertion into an numeric column'
54 $row->discard_changes;
55 is ($row->rank, 'abc', 'proper rank inserted into database');
57 # and make sure we do not lose actual bigints
59 package DBICTest::BigIntArtist;
60 use base 'DBICTest::Schema::Artist';
61 __PACKAGE__->table('artist');
62 __PACKAGE__->add_column(bigint => { data_type => 'bigint' });
64 $schema->register_class(BigIntArtist => 'DBICTest::BigIntArtist');
65 $schema->storage->dbh_do(sub {
66 $_[1]->do('ALTER TABLE artist ADD COLUMN bigint BIGINT');
69 # test upper/lower boundaries for sqlite and some values inbetween
70 # range is -(2**63) .. 2**63 - 1
87 $row = $schema->resultset('BigIntArtist')->create({ bigint => $bi });
88 is ($row->bigint, $bi, "value in object correct ($bi)");
91 local $TODO = 'This perl does not seem to have 64bit int support - DBI roundtrip of large int will fail'
92 unless $Config{ivsize} >= 8;
94 $row->discard_changes;
95 is ($row->bigint, $bi, "value in database correct ($bi)");