8 my $schema = DBICTest->init_schema();
12 # add some rows inside a transaction and commit it
13 # XXX: Is storage->dbh the only way to get a dbh?
14 $schema->storage->txn_begin;
16 $schema->resultset("Artist")->create( {
18 name => "artist number $_",
21 $schema->storage->txn_commit;
22 my ($artist) = $schema->resultset("Artist")->find(15);
23 is($artist->name, 'artist number 15', "Commit ok");
25 # add some rows inside a transaction and roll it back
26 $schema->storage->txn_begin;
28 $schema->resultset("Artist")->create( {
30 name => "artist number $_",
33 $schema->storage->txn_rollback;
34 ($artist) = $schema->resultset("Artist")->search( artistid => 25 );
35 is($artist, undef, "Rollback ok");
38 get_storage_column_info ($schema->storage, 'collection'),
41 data_type => 'INTEGER',
45 data_type => 'varchar',
49 'Correctly retrieve column info (all columns non-nullable)'
53 local $TODO = 'All current versions of SQLite seem to mis-report is_nullable';
56 get_storage_column_info ($schema->storage, 'artist'),
59 'data_type' => 'INTEGER',
63 'data_type' => 'varchar',
67 'data_type' => 'integer',
71 'Correctly retrieve column info (mixed null and non-null columns)'
76 sub get_storage_column_info {
77 my ($storage, $table) = @_;
79 my $type_info = $storage->columns_info_for($table);
81 # I know this is gross but SQLite reports the size differently from release
82 # to release. At least this way the test still passes.
83 # Also it seems that some SQLite releases report stuff that isn't there as
84 # undef. So strip them out.
85 for my $col (keys %$type_info) {
86 for my $type (keys %{$type_info->{$col}}) {
87 if ($type eq 'size' or not defined $type_info->{$col}{$type} ) {
88 delete $type_info->{$col}{$type};