15 my $schema = DBICTest->init_schema(auto_savepoint => 1);
17 my $ars = $schema->resultset('Artist');
19 # test two-phase commit and inner transaction rollback from nested transactions
21 $ars->create({ name => 'in_outer_transaction' });
23 $ars->create({ name => 'in_inner_transaction' });
25 ok($ars->search({ name => 'in_inner_transaction' })->first,
26 'commit from inner transaction visible in outer transaction');
29 $ars->create({ name => 'in_inner_transaction_rolling_back' });
30 die 'rolling back inner transaction';
32 } qr/rolling back inner transaction/, 'inner transaction rollback executed';
33 $ars->create({ name => 'in_outer_transaction2' });
36 ok($ars->search({ name => 'in_outer_transaction' })->first,
37 'commit from outer transaction');
38 ok($ars->search({ name => 'in_outer_transaction2' })->first,
39 'second commit from outer transaction');
40 ok($ars->search({ name => 'in_inner_transaction' })->first,
41 'commit from inner transaction');
42 is $ars->search({ name => 'in_inner_transaction_rolling_back' })->first,
44 'rollback from inner transaction';
47 my $schema = DBICTest->init_schema();
49 # make sure the side-effects of RT#67581 do not result in data loss
51 warnings_exist { $row = $schema->resultset('Artist')->create ({ name => 'alpha rank', rank => 'abc' }) }
52 [qr/Non-numeric value supplied for column 'rank' despite the numeric datatype/],
53 'proper warning on string insertion into an numeric column'
55 $row->discard_changes;
56 is ($row->rank, 'abc', 'proper rank inserted into database');
58 # and make sure we do not lose actual bigints
60 package DBICTest::BigIntArtist;
61 use base 'DBICTest::Schema::Artist';
62 __PACKAGE__->table('artist');
63 __PACKAGE__->add_column(bigint => { data_type => 'bigint' });
65 $schema->register_class(BigIntArtist => 'DBICTest::BigIntArtist');
66 $schema->storage->dbh_do(sub {
67 $_[1]->do('ALTER TABLE artist ADD COLUMN bigint BIGINT');
70 # test upper/lower boundaries for sqlite and some values inbetween
71 # range is -(2**63) .. 2**63 - 1
89 $row = $schema->resultset('BigIntArtist')->create({ bigint => $bi });
90 } 'inserted a bigint';
91 is (try { $row->bigint }, $bi, "value in object correct ($bi)");
94 local $TODO = 'This perl does not seem to have 64bit int support - DBI roundtrip of large int will fail'
95 unless $Config{ivsize} >= 8;
97 $row->discard_changes;
98 is (try { $row->bigint }, $bi, "value in database correct ($bi)");
102 my $artists_with_more_than_one_cd = $schema->resultset('Artist')->search({}, {
104 '+select' => [ { count => 'cds.cdid', -as => 'cd_count' } ],
105 '+as' => ['cd_count'],
106 group_by => ['me.artistid'],
107 having => [ { cd_count => { '>' => 1 } } ],
110 my %artist_cd_counts;
113 while (my $row = $artists_with_more_than_one_cd->next) {
114 $artist_cd_counts{ $row->name } = $row->get_column('cd_count');
116 } 'HAVING int comparison query with a bind survived';
118 ok ((keys %artist_cd_counts),
119 'HAVING int comparison query with a bind returned results');