use MooseX::Declare;
class SQL::Translator::Object::Constraint extends SQL::Translator::Object {
use MooseX::Types::Moose qw(ArrayRef Bool HashRef Maybe Str Undef);
- use MooseX::AttributeHelpers;
use SQL::Translator::Types qw(Column Table);
has 'table' => (
);
has 'columns' => (
- metaclass => 'Collection::Hash',
+ traits => ['Hash'],
is => 'rw',
isa => HashRef[Column],
- provides => {
- exists => 'exists_column',
- keys => 'column_ids',
- values => 'get_columns',
- get => 'get_column',
- set => 'add_column',
+ handles => {
+ exists_column => 'exists',
+ column_ids => 'keys',
+ get_columns => 'values',
+ get_column => 'get',
+ add_column => 'set',
+
+ ## compat
+ get_fields => 'values',
+ fields => 'keys',
},
default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
);
has 'deferrable' => (
is => 'rw',
isa => Bool,
- default => 0
+ default => 1
);
has 'expression' => (
);
has 'reference_columns' => (
- isa => ArrayRef | Undef,
- is => 'rw',
- auto_deref => 1
+ isa => ArrayRef,
+ traits => ['Array'],
+ handles => {
+ reference_columns => 'elements',
+ },
+ default => sub { [] },
);
has 'match_type' => (
around add_column(Column $column) { $self->$orig($column->name, $column) }
- method get_fields { $self->get_columns }
- method fields { $self->column_ids }
- method field_names { $self->column_ids }
-
method reference_fields { $self->reference_columns }
}