Re: [CDBI] Re: ANNOUNCE: Ima::DBI 0.35 released
Brad Bowman <[email protected]> Wed, 13 Jun 2007 10:09:07 +1000
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
Matt S Trout wrote:
> On Tue, Jun 12, 2007 at 10:12:27PM +1000, Brad Bowman wrote:
>> Matt S Trout wrote:
>>> On Tue, Jun 12, 2007 at 10:07:55AM +1000, Brad Bowman wrote:
>>>> I ended up looking at the prepare_cached handling in Ima::DBI and CDBI
>>>> while trying to work around DBD::SQLite's schema error:
>>>> "DBD::SQLite::db selectrow_array failed: database schema has changed(1)"
>>> I'd love a test case against DBD::SQLite for this.
>> It seems a bit tricky to catch these errors are they're from the
>> bowels of dbdimp.c, eval { } doesn't work.
>
> Would setting RaiseError change that?
I'd forgotten about RaiseError. Yes, that makes the test fail nicely.
It doesn't prevent the "database schema has changed" message from
going to stderr, but that shouldn't matter.
Brad
--
Learning is a good thing. But more often it leads to mistakes. ...
For the most part we admire of our own opinions and become fond of arguing.
-- Hagakure http://bereft.net/hagakure/
_______________________________________________
ClassDBI mailing list
ClassDBI-Ra3b/[email protected]
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
bsb_schema_change.t
(text/troff, 636 B)
$|++;
use strict;
use warnings;
use Test;
BEGIN { plan tests => 5 }
use DBI;
my $dbname = "foo$$";
my $dbh = DBI->connect("dbi:SQLite:dbname=$dbname", "", "",
{ RaiseError => 1 });
ok($dbh);
$dbh->{AutoCommit} = 1;
$dbh->do("CREATE TABLE f (f1, f2, f3)");
my $sth = $dbh->prepare_cached("SELECT f.f1, f.* FROM f");
ok($sth);
$dbh->do("ANALYZE"); # invalidate prepared statement handles
my $sth2 = $dbh->prepare_cached("SELECT f.f1, f.* FROM f");
ok($sth2);
my $ret = eval { $sth2->execute(); "ok" };
ok($@, '');
ok($ret, 'ok');
$sth2->finish;
undef $sth2;
$dbh->disconnect;
END {
unlink $dbname;
}