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', qw/size is_nullable/),
41 data_type => 'INTEGER',
44 data_type => 'varchar',
47 'Correctly retrieve column info (no size or is_nullable)'
52 get_storage_column_info ($schema->storage, 'artist', qw/size/),
55 'data_type' => 'INTEGER',
59 'data_type' => 'varchar',
63 'data_type' => 'integer',
65 'default_value' => '13',
68 'data_type' => 'char',
72 'Correctly retrieve column info (mixed null and non-null columns)'
77 # Depending on test we need to strip away certain column info.
78 # - SQLite is known to report the size differently from release to release
79 # - Current DBD::SQLite versions do not implement NULLABLE
80 # - Some SQLite releases report stuff that isn't there as undef
82 sub get_storage_column_info {
83 my ($storage, $table, @ignore) = @_;
85 my $type_info = $storage->columns_info_for($table);
87 for my $col (keys %$type_info) {
88 for my $type (keys %{$type_info->{$col}}) {
90 grep { $type eq $_ } (@ignore)
92 not defined $type_info->{$col}{$type}
94 delete $type_info->{$col}{$type};