From: Justin Hunter Date: Sat, 20 Jun 2009 23:22:52 +0000 (-0700) Subject: add MXAH X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e157d782d0fd81839c38b9f8aab0e1844c14ab9b;p=dbsrgits%2FSQL-Translator-2.0-ish.git add MXAH --- diff --git a/lib/SQL/Translator/Object/Column.pm b/lib/SQL/Translator/Object/Column.pm index e6a31b4..7eb1b6c 100644 --- a/lib/SQL/Translator/Object/Column.pm +++ b/lib/SQL/Translator/Object/Column.pm @@ -38,20 +38,26 @@ has 'is_auto_increment' => ( has 'default_value' => ( is => 'rw', - isa => Str, + isa => Maybe[Str], required => 0 ); -has 'trigger' => ( +has 'index' => ( is => 'rw', - isa => Trigger, + isa => Maybe[Int], + required => 1 +); + +has 'remarks' => ( + is => 'rw', + isa => Maybe[Str], required => 0 ); -has 'index' => ( +has 'trigger' => ( is => 'rw', - isa => Int, - required => 1 + isa => Trigger, + required => 0 ); 1; diff --git a/lib/SQL/Translator/Object/Constraint.pm b/lib/SQL/Translator/Object/Constraint.pm index b3b0674..23d40dc 100644 --- a/lib/SQL/Translator/Object/Constraint.pm +++ b/lib/SQL/Translator/Object/Constraint.pm @@ -1,6 +1,7 @@ package SQL::Translator::Object::Constraint; use Moose; use MooseX::Types::Moose qw(HashRef Str); +use MooseX::AttributeHelpers; use SQL::Translator::Types qw(Column); extends 'SQL::Translator::Object'; @@ -11,8 +12,15 @@ has 'name' => ( ); has 'columns' => ( + metaclass => 'Collection::Hash', is => 'rw', isa => HashRef[Column], + provides => { + exists => 'exists_column', + keys => 'column_ids', + get => 'get_column', + set => 'set_column', + }, required => 1 ); diff --git a/lib/SQL/Translator/Object/Index.pm b/lib/SQL/Translator/Object/Index.pm index ffe5e74..931ca0c 100644 --- a/lib/SQL/Translator/Object/Index.pm +++ b/lib/SQL/Translator/Object/Index.pm @@ -1,6 +1,7 @@ package SQL::Translator::Object::Index; use Moose; use MooseX::Types::Moose qw(HashRef Str); +use MooseX::AttributeHelpers; use SQL::Translator::Types qw(Column); extends 'SQL::Translator::Object'; @@ -11,8 +12,15 @@ has 'name' => ( ); has 'columns' => ( + metaclass => 'Collection::Hash', is => 'rw', isa => HashRef[Column], + provides => { + exists => 'exists_column', + keys => 'column_ids', + get => 'get_column', + set => 'set_column', + }, required => 1 ); diff --git a/lib/SQL/Translator/Object/Procedure.pm b/lib/SQL/Translator/Object/Procedure.pm index fa695cd..ebc4faa 100644 --- a/lib/SQL/Translator/Object/Procedure.pm +++ b/lib/SQL/Translator/Object/Procedure.pm @@ -1,6 +1,7 @@ package SQL::Translator::Object::Procedure; use Moose; use MooseX::Types::Moose qw(HashRef Int Maybe Str); +use MooseX::AttributeHelpers; use SQL::Translator::Types qw(); use SQL::Translator::Object::Schema; extends 'SQL::Translator::Object'; @@ -18,8 +19,15 @@ has 'contents' => ( ); has 'parameters' => ( + metaclass => 'Collection::Hash', is => 'rw', isa => Maybe[HashRef[Int|Str]], + provides => { + exists => 'exists_parameter', + keys => 'parameter_ids', + get => 'get_parameter', + set => 'set_parameter', + }, required => 0 ); diff --git a/lib/SQL/Translator/Object/Schema.pm b/lib/SQL/Translator/Object/Schema.pm index cc82b13..42b9901 100644 --- a/lib/SQL/Translator/Object/Schema.pm +++ b/lib/SQL/Translator/Object/Schema.pm @@ -1,6 +1,7 @@ package SQL::Translator::Object::Schema; use Moose; use MooseX::Types::Moose qw(HashRef Str); +use MooseX::AttributeHelpers; use SQL::Translator::Types qw(Procedure Table View); extends 'SQL::Translator::Object'; @@ -12,20 +13,41 @@ has 'name' => ( ); has 'tables' => ( + metaclass => 'Collection::Hash', is => 'rw', isa => HashRef[Table], + provides => { + exists => 'exists_table', + keys => 'table_ids', + get => 'get_table', + set => 'set_table', + }, required => 0 ); has 'views' => ( + metaclass => 'Collection::Hash', is => 'rw', isa => HashRef[View], + provides => { + exists => 'exists_view', + keys => 'view_ids', + get => 'get_view', + set => 'set_view', + }, required => 0 ); has 'procedures' => ( + metaclass => 'Collection::Hash', is => 'rw', isa => HashRef[Procedure], + provides => { + exists => 'exists_procedure', + keys => 'procedure_ids', + get => 'get_procedure', + set => 'set_procedure', + }, required => 0 ); diff --git a/lib/SQL/Translator/Object/Table.pm b/lib/SQL/Translator/Object/Table.pm index 4b795d5..a91ca9c 100644 --- a/lib/SQL/Translator/Object/Table.pm +++ b/lib/SQL/Translator/Object/Table.pm @@ -2,13 +2,12 @@ package SQL::Translator::Object::Table; use Moose; use MooseX::Types::Moose qw(HashRef Str); use MooseX::AttributeHelpers; -#use MooseX::Types::Set::Object; use SQL::Translator::Types qw(Column Constraint Index Schema); use SQL::Translator::Object::Schema; extends 'SQL::Translator::Object'; has 'name' => ( - is => 'ro', + is => 'rw', isa => Str, required => 1 ); @@ -17,13 +16,25 @@ has 'columns' => ( metaclass => 'Collection::Hash', is => 'rw', isa => HashRef[Column], - required => 1 + provides => { + exists => 'exists_column', + keys => 'column_ids', + get => 'get_column', + set => 'set_column', + }, + required => 0 ); has 'indexes' => ( metaclass => 'Collection::Hash', is => 'rw', isa => HashRef[Index], + provides => { + exists => 'exists_index', + keys => 'index_ids', + get => 'get_index', + set => 'set_index', + }, required => 0 ); @@ -31,13 +42,19 @@ has 'constraints' => ( metaclass => 'Collection::Hash', is => 'rw', isa => HashRef[Constraint], + provides => { + exists => 'exists_constraint', + keys => 'constraint_ids', + get => 'get_constraint', + set => 'set_constraint', + }, required => 0 ); has 'schema' => ( - is => 'ro', + is => 'rw', isa => Schema, - required => 1, + required => 0, default => sub { SQL::Translator::Object::Schema->new } );