From: Justin Hunter Date: Wed, 6 Jan 2010 06:16:17 +0000 (-0800) Subject: bring Procedure up to speed with the rest of the Objects X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f228f0682d18dd5af84e7e8c0a2fa7aa36dcdec2;p=dbsrgits%2FSQL-Translator-2.0-ish.git bring Procedure up to speed with the rest of the Objects --- diff --git a/lib/SQL/Translator/Object/Compat.pm b/lib/SQL/Translator/Object/Compat.pm index 1a7a030..c640529 100644 --- a/lib/SQL/Translator/Object/Compat.pm +++ b/lib/SQL/Translator/Object/Compat.pm @@ -1,7 +1,7 @@ use MooseX::Declare; role SQL::Translator::Object::Compat { use MooseX::Types qw(Any ArrayRef Int Str); - use SQL::Translator::Types qw(Column Constraint Index Table Trigger View); + use SQL::Translator::Types qw(Column Constraint Index Procedure Table Trigger View); use MooseX::MultiMethods; @@ -31,6 +31,7 @@ role SQL::Translator::Object::Compat { method drop_column(Column|Str $column, Int :$cascade = 0) { $self->remove_column($column, cascade => $cascade) } method drop_constraint(Constraint|Str $constraint) { $self->remove_constraint($constraint) } method drop_index(Index|Str $index) { $self->remove_index($index) } + method drop_procedure(Procedure|Str $procedure) { $self->remove_procedure($procedure) } method drop_table(Table|Str $table, Int :$cascade = 0) { $self->remove_table($table, cascade => $cascade) } method drop_trigger(Trigger|Str $trigger) { $self->remove_trigger($trigger) } method drop_view(View|Str $view) { $self->remove_view($view) } diff --git a/lib/SQL/Translator/Object/Procedure.pm b/lib/SQL/Translator/Object/Procedure.pm index d1cc90e..587b6b3 100644 --- a/lib/SQL/Translator/Object/Procedure.pm +++ b/lib/SQL/Translator/Object/Procedure.pm @@ -2,6 +2,13 @@ use MooseX::Declare; class SQL::Translator::Object::Procedure extends SQL::Translator::Object { use MooseX::Types::Moose qw(ArrayRef Str); use MooseX::MultiMethods; + use SQL::Translator::Types qw(Schema); + + has 'schema' => ( + is => 'rw', + isa => Schema, + weak_ref => 1, + ); has 'name' => ( is => 'rw', @@ -35,5 +42,5 @@ class SQL::Translator::Object::Procedure extends SQL::Translator::Object { multi method parameters(Str $parameter) { $self->add_parameter($parameter) } multi method parameters(ArrayRef $parameter) { $self->add_parameter($parameter) } - multi method parameters { wantarray ? @{$self->_parameters} : $self->_parameters } + multi method parameters { wantarray ? $self->_parameters : $self->_parameters } } diff --git a/lib/SQL/Translator/Object/Schema.pm b/lib/SQL/Translator/Object/Schema.pm index 446c553..4f02431 100644 --- a/lib/SQL/Translator/Object/Schema.pm +++ b/lib/SQL/Translator/Object/Schema.pm @@ -88,7 +88,11 @@ class SQL::Translator::Object::Schema extends SQL::Translator::Object { $self->$orig($view->name, $view) } - around add_procedure(Procedure $procedure does coerce) { $self->$orig($procedure->name, $procedure) } + around add_procedure(Procedure $procedure does coerce) { + $procedure->schema($self); + $self->$orig($procedure->name, $procedure) + } + around add_trigger(Trigger $trigger does coerce) { $trigger->schema($self); $self->$orig($trigger->name, $trigger);;