9 package DBICTest::ExplodingStorage::Sth;
13 sub execute { die "Kablammo!" }
17 package DBICTest::ExplodingStorage;
20 use base 'DBIx::Class::Storage::DBI::SQLite';
24 my ($self, $sql) = @_;
25 return bless {}, "DBICTest::ExplodingStorage::Sth" unless $count++;
26 return $self->next::method($sql);
30 return 0 if $count == 1;
31 return shift->next::method(@_);
37 my $schema = DBICTest->init_schema();
39 is( ref($schema->storage), 'DBIx::Class::Storage::DBI::SQLite',
40 'Storage reblessed correctly into DBIx::Class::Storage::DBI::SQLite' );
42 my $storage = $schema->storage;
43 $storage->ensure_connected;
46 $schema->storage->throw_exception('test_exception_42');
48 like($@, qr/\btest_exception_42\b/, 'basic exception');
51 $schema->resultset('CD')->search_literal('broken +%$#$1')->all;
53 like($@, qr/prepare_cached failed/, 'exception via DBI->HandleError, etc');
55 bless $storage, "DBICTest::ExplodingStorage";
56 $schema->storage($storage);
59 $schema->resultset('Artist')->create({ name => "Exploding Sheep" });
62 is($@, "", "Exploding \$sth->execute was caught");
64 is(1, $schema->resultset('Artist')->search({name => "Exploding Sheep" })->count,
65 "And the STH was retired");
67 my $info = { on_connect_do => [] };
69 $storage->connect_info(['foo','bar','baz',$info]);
71 ok(exists($info->{on_connect_do}), q{Didn't kill key passed to storage});