From: Justin Hunter Date: Sun, 21 Jun 2009 13:57:59 +0000 (-0700) Subject: fix some schema object issues X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=61c819e0ee473bf200cc6d7330dd9d2e9e5ec28a;p=dbsrgits%2FSQL-Translator-2.0-ish.git fix some schema object issues --- diff --git a/lib/SQL/Translator/Parser/DBI/MySQL.pm b/lib/SQL/Translator/Parser/DBI/MySQL.pm index b06a4cc..427e325 100644 --- a/lib/SQL/Translator/Parser/DBI/MySQL.pm +++ b/lib/SQL/Translator/Parser/DBI/MySQL.pm @@ -1,7 +1,8 @@ package SQL::Translator::Parser::DBI::MySQL; use Moose; +use SQL::Translator::Types qw(Schema); with 'SQL::Translator::Parser::DBI::Dialect'; -has 'schema' => (is => 'ro', isa => Str, default => { sub { SQL::Translator::Object::Schema->new( { name => '' })); +has 'schema' => (is => 'ro', isa => Schema, default => sub { SQL::Translator::Object::Schema->new( { name => '' }) }); 1; diff --git a/lib/SQL/Translator/Parser/DBI/Oracle.pm b/lib/SQL/Translator/Parser/DBI/Oracle.pm index 437c0c1..7137c1a 100644 --- a/lib/SQL/Translator/Parser/DBI/Oracle.pm +++ b/lib/SQL/Translator/Parser/DBI/Oracle.pm @@ -1,7 +1,8 @@ package SQL::Translator::Parser::DBI::Oracle; use Moose; +use SQL::Translator::Types qw(Schema); with 'SQL::Translator::Parser::DBI::Dialect'; -has 'schema' => (is => 'ro', isa => Str, default => { sub { SQL::Translator::Object::Schema->new( { name => '' })); +has 'schema' => (is => 'ro', isa => Schema, default => sub { SQL::Translator::Object::Schema->new( { name => '' }) }); 1; diff --git a/lib/SQL/Translator/Parser/DBI/SQLite.pm b/lib/SQL/Translator/Parser/DBI/SQLite.pm index b9fbac9..e190a22 100644 --- a/lib/SQL/Translator/Parser/DBI/SQLite.pm +++ b/lib/SQL/Translator/Parser/DBI/SQLite.pm @@ -1,25 +1,25 @@ package SQL::Translator::Parser::DBI::SQLite; use Moose; -use MooseX::Types::Moose qw(Str); -use SQL::Translator::Types qw(DBIHandle); +use SQL::Translator::Types qw(Schema); +use SQL::Translator::Object::Table; with 'SQL::Translator::Parser::DBI::Dialect'; -has 'schema' => (is => 'ro', isa => Str, default => { sub { SQL::Translator::Object::Schema->new( { name => '' })); +has 'schema' => (is => 'ro', isa => Schema, default => sub { SQL::Translator::Object::Schema->new( { name => '' }) }); sub _tables_list { my $self = shift; my $dbh = $self->dbh; - my $sth = $dbh->prepare("SELECT * FROM sqlite_master"); + my $sth = $dbh->prepare("SELECT * FROM sqlite_master WHERE type = 'table'"); $sth->execute; - my @tables; + + my %tables; while ( my $row = $sth->fetchrow_hashref ) { - next unless lc( $row->{type} ) eq 'table'; next if $row->{tbl_name} =~ /^sqlite_/; - push @tables, $row->{tbl_name}; + $tables{$row->{tbl_name}} = SQL::Translator::Object::Table->new( { name => $row->{tbl_name}, schema => $self->schema } ); } $sth->finish; - return @tables; + return \%tables; } 1; diff --git a/lib/SQL/Translator/Parser/DBI/Sybase.pm b/lib/SQL/Translator/Parser/DBI/Sybase.pm index 0581c04..1022481 100644 --- a/lib/SQL/Translator/Parser/DBI/Sybase.pm +++ b/lib/SQL/Translator/Parser/DBI/Sybase.pm @@ -1,7 +1,8 @@ package SQL::Translator::Parser::DBI::Sybase; use Moose; +use SQL::Translator::Types qw(Schema); with 'SQL::Translator::Parser::DBI::Dialect'; -has 'schema' => (is => 'ro', isa => Str, default => { sub { SQL::Translator::Object::Schema->new( { name => '' })); +has 'schema' => (is => 'ro', isa => Schema, default => sub { SQL::Translator::Object::Schema->new( { name => '' }) }); 1;