From: Justin Hunter Date: Wed, 29 Jul 2009 15:07:20 +0000 (-0700) Subject: allow detection of ddl parser X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=15adaf1898a9611bd6d177fbf1a105ed1e527810;p=dbsrgits%2FSQL-Translator-2.0-ish.git allow detection of ddl parser --- diff --git a/lib/SQL/Translator.pm b/lib/SQL/Translator.pm index bd07882..567c005 100644 --- a/lib/SQL/Translator.pm +++ b/lib/SQL/Translator.pm @@ -49,7 +49,14 @@ class SQL::Translator { Class::MOP::load_class($class); - my $parser = $class->new({ dbh => $self->dbh }); + my $parser; + if ($self->has_dbh) { + $parser = $class->new({ dbh => $self->dbh }); + } elsif ($self->has_ddl) { + $parser = $class->new({ filename => $self->filename, type => $self->parser }); + } else { + die "dbh or filename is required!"; + } return $parser; } @@ -66,5 +73,4 @@ class SQL::Translator { return $producer; } - }