existing Loader patchwork for Schema support, module not fully renamed yet
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Loader / SQLite.pm
index 466253f..61be9ab 100644 (file)
@@ -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