From: Justin Hunter Date: Mon, 17 Aug 2009 19:40:31 +0000 (-0700) Subject: add a ref to the translator object that created the producer and keep the schema... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=362da5e982e150dd4bf9d7c39582853f00df96ed;p=dbsrgits%2FSQL-Translator-2.0-ish.git add a ref to the translator object that created the producer and keep the schema in it --- diff --git a/lib/SQL/Translator/Producer.pm b/lib/SQL/Translator/Producer.pm index 397ee0e..51324f9 100644 --- a/lib/SQL/Translator/Producer.pm +++ b/lib/SQL/Translator/Producer.pm @@ -2,13 +2,7 @@ use MooseX::Declare; class SQL::Translator::Producer { use SQL::Translator::Constants qw(:sqlt_types); use MooseX::Types::Moose qw(Bool HashRef Str); - use SQL::Translator::Types qw(Column Schema Table); - - has 'schema' => ( - isa => Schema, - is => 'rw', - required => 1 - ); + use SQL::Translator::Types qw(Column Table Translator); has 'no_comments' => ( isa => Bool, @@ -30,6 +24,14 @@ class SQL::Translator::Producer { lazy_build => 1 ); + has 'translator' => ( + isa => Translator, + is => 'ro', + weak_ref => 1, + required => 1, + handles => [ qw(schema) ], + ); + method _build_data_type_mapping { return { SQL_LONGVARCHAR() => 'text', @@ -46,7 +48,7 @@ class SQL::Translator::Producer { method produce { my $schema = $self->schema; - + $self->_create_table($_) for values %{$schema->tables}; }