Commit | Line | Data |
70350518 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | |
a47e1233 |
8 | my $schema = DBICTest->init_schema(); |
70350518 |
9 | |
a953d8d9 |
10 | plan tests => 3; |
0567538f |
11 | |
12 | # add some rows inside a transaction and commit it |
13 | # XXX: Is storage->dbh the only way to get a dbh? |
f9db5527 |
14 | $schema->storage->txn_begin; |
0567538f |
15 | for (10..15) { |
f9db5527 |
16 | $schema->resultset("Artist")->create( { |
0567538f |
17 | artistid => $_, |
18 | name => "artist number $_", |
19 | } ); |
20 | } |
f9db5527 |
21 | $schema->storage->txn_commit; |
22 | my ($artist) = $schema->resultset("Artist")->find(15); |
0567538f |
23 | is($artist->name, 'artist number 15', "Commit ok"); |
24 | |
0567538f |
25 | # add some rows inside a transaction and roll it back |
f9db5527 |
26 | $schema->storage->txn_begin; |
0567538f |
27 | for (21..30) { |
f9db5527 |
28 | $schema->resultset("Artist")->create( { |
0567538f |
29 | artistid => $_, |
30 | name => "artist number $_", |
31 | } ); |
32 | } |
f9db5527 |
33 | $schema->storage->txn_rollback; |
34 | ($artist) = $schema->resultset("Artist")->search( artistid => 25 ); |
0567538f |
35 | is($artist, undef, "Rollback ok"); |
36 | |
a953d8d9 |
37 | my $type_info = $schema->storage->columns_info_for('artist'); |
b3caf56c |
38 | |
39 | # I know this is gross but SQLite reports the size differently from release |
40 | # to release. At least this way the test still passes. |
a4691709 |
41 | # Also it seems that some SQLite releases report stuff that isn't there as |
42 | # undef. So strip them out. |
43 | for my $col (keys %$type_info) { |
44 | for my $type (keys %{$type_info->{$col}}) { |
45 | if ($type eq 'size' or not defined $type_info->{$col}{$type} ) { |
46 | delete $type_info->{$col}{$type}; |
47 | } |
48 | } |
49 | } |
b3caf56c |
50 | |
a953d8d9 |
51 | my $test_type_info = { |
52 | 'artistid' => { |
fc22fbac |
53 | 'data_type' => 'INTEGER', |
54 | 'is_nullable' => 0, |
a953d8d9 |
55 | }, |
56 | 'name' => { |
fc22fbac |
57 | 'data_type' => 'varchar', |
58 | 'is_nullable' => 0, |
93cec8c3 |
59 | }, |
39da2a2b |
60 | 'rank' => { |
61 | 'data_type' => 'integer', |
62 | 'is_nullable' => 0, |
63 | }, |
a953d8d9 |
64 | }; |
65 | is_deeply($type_info, $test_type_info, 'columns_info_for - column data types'); |
66 | |