Re: [CDBI] Re: ANNOUNCE: Ima::DBI 0.35 released
Matt S Trout <dbix-class-uY5y5/[email protected]> Tue, 12 Jun 2007 17:20:57 +0100
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
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?
> Depending on the purpose and portability needs of the tests, something
> could be hacked up with redirects. I'm not sure what else to try,
> any suggestions?
>
> The attached test currently passes, but still produces the error
> message on stderr. I'm trying this within DBD-SQLite-1.13.
>
>
> Brad
>
> --
> That one's own district is unsophisticated and unpolished is a great
> treasure. Imitating another style is simply a sham.
> -- Hagakure http://bereft.net/hagakure/
> $|++;
> use strict;
> use warnings;
> use Test;
> BEGIN { plan tests => 5 }
> use DBI;
>
> my $dbname = "foo$$";
> my $dbh = DBI->connect("dbi:SQLite:dbname=$dbname", "", "");
> 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;
> }
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director Want a managed development or deployment platform?
Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/