From: Andrew Rodland Date: Thu, 25 Feb 2010 10:58:33 +0000 (-0600) Subject: Do that eval a little more nicely. X-Git-Tag: 0.06000~79 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a7ada784e684316dc3d0e633b20c4032b5976b5e;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Do that eval a little more nicely. --- diff --git a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm index aadaf57..7221cb8 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm @@ -55,17 +55,16 @@ sub _extra_column_info { my %extra_info; my $dbh = $self->schema->storage->dbh; - my $get_seq; - eval { - $get_seq = $self->{_cache}->{sqlite_sequence} + my $has_autoinc = eval { + my $get_seq = $self->{_cache}->{sqlite_sequence} ||= $dbh->prepare(q{SELECT count(*) FROM sqlite_sequence WHERE name = ?}); $get_seq->execute($table); + my ($ret) = $get_seq->fetchrow_array; + $get_seq->finish; + $ret; }; - return {} if $@; - my ($has_autoinc) = $get_seq->fetchrow_array; - $get_seq->finish; - if ($has_autoinc) { + if (!$@ && $has_autoinc) { my $sth = $dbh->prepare( "pragma table_info(" . $dbh->quote_identifier($table) . ")" );