use MooseX::Types::Moose qw(Int Maybe ScalarRef Str);
use MooseX::MultiMethods;
use SQL::Translator::Types qw(Bit Constraint Table Trigger);
+ use Tie::IxHash;
clean;
use overload
class SQL::Translator::Object::Constraint extends SQL::Translator::Object {
use MooseX::Types::Moose qw(ArrayRef Bool HashRef Int Maybe Str Undef);
use MooseX::MultiMethods;
- use SQL::Translator::Types qw(Column MatchType Table);
+ use SQL::Translator::Types qw(Column MatchType Table ColumnHash IxHash);
+ use Tie::IxHash;
has 'table' => (
is => 'rw',
);
has 'columns' => (
- traits => ['Hash'],
is => 'rw',
- isa => HashRef[Column],
+ isa => IxHash, #ColumnHash,
handles => {
- exists_column => 'exists',
- column_ids => 'keys',
- get_columns => 'values',
- get_column => 'get',
- add_column => 'set',
- clear_columns => 'clear',
+ exists_column => 'EXISTS',
+ column_ids => 'Keys',
+ get_columns => 'Values',
+ get_column => 'FETCH',
+ add_column => 'STORE',
+ remove_column => 'DELETE',
+ clear_columns => 'CLEAR',
},
- default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
+ coerce => 1,
+ default => sub { Tie::IxHash->new() }
);
has 'type' => (
class SQL::Translator::Object::Index extends SQL::Translator::Object {
use MooseX::Types::Moose qw(HashRef Str);
use MooseX::MultiMethods;
- use SQL::Translator::Types qw(Column Table);
+ use SQL::Translator::Types qw(Column Table ColumnHash IxHash);
+ use Tie::IxHash;
has 'table' => (
is => 'rw',
);
has 'columns' => (
- traits => ['Hash'],
is => 'rw',
- isa => HashRef[Column],
+ isa => IxHash, #ColumnHash,
handles => {
- exists_column => 'exists',
- column_ids => 'keys',
- get_columns => 'values',
- get_column => 'get',
- add_column => 'set',
- clear_columns => 'clear',
+ exists_column => 'EXISTS',
+ column_ids => 'Keys',
+ get_columns => 'Values',
+ get_column => 'FETCH',
+ add_column => 'STORE',
+ remove_column => 'DELETE',
+ clear_columns => 'CLEAR',
},
- default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
+ coerce => 1,
+ default => sub { Tie::IxHash->new() }
);
has 'type' => (
use MooseX::Declare;
class SQL::Translator::Object::Schema extends SQL::Translator::Object {
use MooseX::Types::Moose qw(HashRef Maybe Str);
- use SQL::Translator::Types qw(Procedure Table Trigger View);
use MooseX::MultiMethods;
+ use Tie::IxHash;
+ use SQL::Translator::Types qw(Procedure Table Trigger View ProcedureHash TableHash TriggerHash ViewHash IxHash);
has 'name' => (
is => 'rw',
class SQL::Translator::Object::Table extends SQL::Translator::Object is dirty {
use MooseX::Types::Moose qw(Any Bool HashRef Int Str);
use MooseX::MultiMethods;
- use SQL::Translator::Types qw(Column Constraint Index Schema Sequence);
+ use SQL::Translator::Types qw(Column Constraint Index Schema Sequence ColumnHash ConstraintHash IndexHash SequenceHash IxHash);
use SQL::Translator::Object::Column;
use SQL::Translator::Object::Constraint;
+ use Tie::IxHash;
clean;
use overload
);
has 'columns' => (
- traits => ['Hash'],
is => 'rw',
- isa => HashRef[Column],
+ isa => IxHash, #ColumnHash,
handles => {
- exists_column => 'exists',
- column_ids => 'keys',
- get_columns => 'values',
- get_column => 'get',
- add_column => 'set',
- remove_column => 'delete',
- clear_columns => 'clear',
+ exists_column => 'EXISTS',
+ column_ids => 'Keys',
+ get_columns => 'Values',
+ get_column => 'FETCH',
+ add_column => 'STORE',
+ remove_column => 'DELETE',
+ has_columns => 'Length',
+ clear_columns => 'CLEAR',
},
- default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
+ coerce => 1,
+ default => sub { Tie::IxHash->new() }
);
has 'indexes' => (
- traits => ['Hash'],
is => 'rw',
- isa => HashRef[Index],
+ isa => IxHash, #IndexHash,
handles => {
- exists_index => 'exists',
- index_ids => 'keys',
- get_indices => 'values',
- get_index => 'get',
- add_index => 'set',
- remove_index => 'delete',
+ exists_index => 'EXISTS',
+ index_ids => 'Keys',
+ get_indices => 'Values',
+ get_index => 'FETCH',
+ add_index => 'STORE',
+ remove_index => 'DELETE',
},
- default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
+ coerce => 1,
+ default => sub { Tie::IxHash->new() }
);
has 'constraints' => (
- traits => ['Hash'],
is => 'rw',
- isa => HashRef[Constraint],
+ isa => IxHash, #ConstraintHash,
handles => {
- exists_constraint => 'exists',
- constraint_ids => 'keys',
- get_constraints => 'values',
- get_constraint => 'get',
- add_constraint => 'set',
- remove_constraint => 'delete',
+ exists_constraint => 'EXISTS',
+ constraint_ids => 'Keys',
+ get_constraints => 'Values',
+ get_constraint => 'FETCH',
+ add_constraint => 'STORE',
+ remove_constraint => 'DELETE',
},
- default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
+ coerce => 1,
+ default => sub { Tie::IxHash->new() }
);
has 'sequences' => (
- traits => ['Hash'],
is => 'rw',
- isa => HashRef[Sequence],
+ isa => IxHash, #SequenceHash,
handles => {
- exists_sequence => 'exists',
- sequence_ids => 'keys',
- get_sequences => 'values',
- get_sequence => 'get',
- add_sequence => 'set',
- remove_sequence => 'delete',
+ exists_sequence => 'EXISTS',
+ sequence_ids => 'Keys',
+ get_sequences => 'Values',
+ get_sequence => 'FETCH',
+ add_sequence => 'STORE',
+ remove_sequence => 'DELETE',
},
- default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
+ coerce => 1,
+ default => sub { Tie::IxHash->new() },
);
has 'schema' => (
my $fields = delete $args->{fields};
- tie %{$args->{columns}}, 'Tie::IxHash';
$args->{columns}{$_} = SQL::Translator::Object::Column->new( name => $_ ) for @$fields;
return $args;
class SQL::Translator::Object::Trigger extends SQL::Translator::Object {
use MooseX::Types::Moose qw(Any ArrayRef HashRef Int Str);
use MooseX::MultiMethods;
- use SQL::Translator::Types qw(Column Schema Table);
+ use SQL::Translator::Types qw(Column Schema Table ColumnHash IxHash);
+ use Tie::IxHash;
has 'schema' => (
is => 'rw',
);
has 'columns' => (
- traits => ['Hash'],
is => 'rw',
- isa => HashRef[Column],
+ isa => IxHash, #ColumnHash,
handles => {
- exists_column => 'exists',
- column_ids => 'keys',
- get_columns => 'values',
- get_column => 'get',
- add_column => 'set',
- clear_columns => 'clear',
+ exists_column => 'EXISTS',
+ column_ids => 'Keys',
+ get_columns => 'Values',
+ get_column => 'FETCH',
+ add_column => 'STORE',
+ remove_column => 'DELETE',
+ clear_columns => 'CLEAR',
},
- default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
+ coerce => 1,
+ default => sub { Tie::IxHash->new() }
);
has 'on_table' => (
use MooseX::Declare;
class SQL::Translator::Types {
use MooseX::Types::Moose qw(ArrayRef CodeRef HashRef Int Maybe Str Undef);
+ use MooseX::Types::Parameterizable qw(Parameterizable);
use MooseX::Types -declare, [qw(Column Constraint ForeignKey Index PrimaryKey Procedure Schema Sequence Table Trigger View
- Bit DBIHandle MatchType Parser Producer Translator DBICSchema)];
+ Bit DBIHandle MatchType Parser Producer Translator DBICSchema IxHash
+ ColumnHash ConstraintHash IndexHash ProcedureHash SequenceHash TableHash TriggerHash ViewHash)];
+ use Tie::IxHash;
class_type DBICSchema, { class => 'DBIx::Class::Schema' };
sub coerce_dbihandle_from_str { }
sub coerce_dbihandle_from_arrayref { }
sub coerce_dbihandle_from_coderef { }
-
+
+ subtype IxHash, as 'Tie::IxHash';
+ coerce IxHash, from HashRef, via { Tie::IxHash->new($_) };
+
+ subtype ColumnHash, as Parameterizable[IxHash, Maybe[Column]];
+ subtype ConstraintHash, as Parameterizable[IxHash, Maybe[Constraint]];
+ subtype IndexHash, as Parameterizable[IxHash, Maybe[Index]];
+ subtype ProcedureHash, as Parameterizable[IxHash, Maybe[Procedure]];
+ subtype SequenceHash, as Parameterizable[IxHash, Maybe[Sequence]];
+ subtype TableHash, as Parameterizable[IxHash, Maybe[Table]];
+ subtype TriggerHash, as Parameterizable[IxHash, Maybe[Trigger]];
+ subtype ViewHash, as Parameterizable[IxHash, Maybe[View]];
}