1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
10 my $schema = DBICTest->init_schema();
14 # add some rows inside a transaction and commit it
15 # XXX: Is storage->dbh the only way to get a dbh?
16 $schema->storage->txn_begin;
18 $schema->resultset("Artist")->create( {
20 name => "artist number $_",
23 $schema->storage->txn_commit;
24 my ($artist) = $schema->resultset("Artist")->find(15);
25 is($artist->name, 'artist number 15', "Commit ok");
27 # add some rows inside a transaction and roll it back
28 $schema->storage->txn_begin;
30 $schema->resultset("Artist")->create( {
32 name => "artist number $_",
35 $schema->storage->txn_rollback;
36 ($artist) = $schema->resultset("Artist")->search({ artistid => 25 });
37 is($artist, undef, "Rollback ok");
40 get_storage_column_info ($schema->storage, 'collection', qw/size is_nullable/),
43 data_type => 'INTEGER',
46 data_type => 'varchar',
49 'Correctly retrieve column info (no size or is_nullable)'
54 get_storage_column_info ($schema->storage, 'artist', qw/size/),
57 'data_type' => 'INTEGER',
61 'data_type' => 'varchar',
65 'data_type' => 'integer',
67 DBIx::Class::_ENV_::STRESSTEST_COLUMN_INFO_UNAWARE_STORAGE ? () : ( 'default_value' => '13' ),
70 'data_type' => 'char',
74 'Correctly retrieve column info (mixed null and non-null columns)'
79 # Depending on test we need to strip away certain column info.
80 # - SQLite is known to report the size differently from release to release
81 # - Current DBD::SQLite versions do not implement NULLABLE
82 # - Some SQLite releases report stuff that isn't there as undef
84 sub get_storage_column_info {
85 my ($storage, $table, @ignore) = @_;
87 my $type_info = $storage->columns_info_for($table);
89 for my $col (keys %$type_info) {
90 for my $type (keys %{$type_info->{$col}}) {
92 grep { $type eq $_ } (@ignore)
94 not defined $type_info->{$col}{$type}
96 delete $type_info->{$col}{$type};