X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FLoader%2FSQLite.pm;h=61be9ab1572185924f7dbe252c6e1a79179c7e17;hb=af6c266584e3842998e4c2af0c15d82a089238f4;hp=466253f90b0b35333b28a6da996d806622a7779b;hpb=7a30e845d987244ee30af802906cea6380744860;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Loader/SQLite.pm b/lib/DBIx/Class/Loader/SQLite.pm index 466253f..61be9ab 100644 --- a/lib/DBIx/Class/Loader/SQLite.pm +++ b/lib/DBIx/Class/Loader/SQLite.pm @@ -36,7 +36,7 @@ sub _relationships { my $self = shift; foreach my $table ( $self->tables ) { - my $dbh = $self->find_class($table)->storage->dbh; + my $dbh = $self->{_storage}->dbh; my $sth = $dbh->prepare(<<""); SELECT sql FROM sqlite_master WHERE tbl_name = ? @@ -93,7 +93,7 @@ SELECT sql FROM sqlite_master WHERE tbl_name = ? sub _tables { my $self = shift; - my $dbh = DBI->connect( @{ $self->{_datasource} } ) or croak($DBI::errstr); + my $dbh = $self->{_storage}->dbh; my $sth = $dbh->prepare("SELECT * FROM sqlite_master"); $sth->execute; my @tables; @@ -101,7 +101,6 @@ sub _tables { next unless lc( $row->{type} ) eq 'table'; push @tables, $row->{tbl_name}; } - $dbh->disconnect; return @tables; } @@ -109,7 +108,7 @@ sub _table_info { my ( $self, $table ) = @_; # find all columns. - my $dbh = DBI->connect( @{ $self->{_datasource} } ) or croak($DBI::errstr); + my $dbh = $self->{_storage}->dbh; my $sth = $dbh->prepare("PRAGMA table_info('$table')"); $sth->execute(); my @columns; @@ -125,7 +124,6 @@ SQL $sth->execute($table); my ($sql) = $sth->fetchrow_array; $sth->finish; - $dbh->disconnect; my ($primary) = $sql =~ m/ (?:\(|\,) # either a ( to start the definition or a , for next \s* # maybe some whitespace