From: Jess Robinson Date: Tue, 10 Jun 2008 15:34:02 +0000 (+0000) Subject: Make Schema::Graph only load if "as_graph" is called on a Schema object X-Git-Tag: v0.11008~311 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4c4636ed5857768d97998c890154211a0751ac5a;p=dbsrgits%2FSQL-Translator.git Make Schema::Graph only load if "as_graph" is called on a Schema object --- diff --git a/lib/SQL/Translator/Parser/DBI.pm b/lib/SQL/Translator/Parser/DBI.pm index c42730a..53f0a28 100644 --- a/lib/SQL/Translator/Parser/DBI.pm +++ b/lib/SQL/Translator/Parser/DBI.pm @@ -138,14 +138,6 @@ use Exporter; use SQL::Translator::Utils qw(debug); -use SQL::Translator::Parser::DBI::MySQL; -use SQL::Translator::Parser::DBI::SQLServer; -use SQL::Translator::Parser::DBI::SQLite; -use SQL::Translator::Parser::DBI::Sybase; -use SQL::Translator::Parser::DBI::PostgreSQL; -use SQL::Translator::Parser::DBI::DB2; -use SQL::Translator::Parser::DBI::Oracle; - use base qw(Exporter); @EXPORT = qw(parse); @@ -180,11 +172,7 @@ sub parse { my $pkg = "SQL::Translator::Parser::DBI::$driver"; my $sub = $pkg.'::parse'; - # - # I can't get this to work. I seem to have to have the "use" - # statements above. - # -# $tr->load( $pkg ); + $tr->load( $pkg ); eval { no strict 'refs'; diff --git a/lib/SQL/Translator/Schema.pm b/lib/SQL/Translator/Schema.pm index 03e658a..86ceb67 100644 --- a/lib/SQL/Translator/Schema.pm +++ b/lib/SQL/Translator/Schema.pm @@ -54,7 +54,7 @@ use SQL::Translator::Schema::Procedure; use SQL::Translator::Schema::Table; use SQL::Translator::Schema::Trigger; use SQL::Translator::Schema::View; -use SQL::Translator::Schema::Graph; + use SQL::Translator::Utils 'parse_list_arg'; use base 'SQL::Translator::Schema::Object'; @@ -74,8 +74,10 @@ sub as_graph { Returns the schema as an L object. =cut + require SQL::Translator::Schema::Graph; my $self = shift; + return SQL::Translator::Schema::Graph->new( translator => $self->translator ); } diff --git a/lib/SQL/Translator/Schema/Graph.pm b/lib/SQL/Translator/Schema/Graph.pm index d13c56b..abcf973 100644 --- a/lib/SQL/Translator/Schema/Graph.pm +++ b/lib/SQL/Translator/Schema/Graph.pm @@ -6,7 +6,7 @@ use Data::Dumper; local $Data::Dumper::Maxdepth = 3; use Log::Log4perl qw(:easy); -Log::Log4perl->easy_init($ERROR); +Log::Log4perl->easy_init($ERROR) unless Log::Log4perl->initialized(); use SQL::Translator::Schema::Graph::Node; use SQL::Translator::Schema::Graph::Edge; use SQL::Translator::Schema::Graph::Port;