remove needless alias
[dbsrgits/SQL-Translator-2.0-ish.git] / lib / SQL / Translator / Object / Constraint.pm
CommitLineData
4f4fd192 1use MooseX::Declare;
ebf2721d 2class SQL::Translator::Object::Constraint extends SQL::Translator::Object {
f49a2a49 3 use MooseX::Types::Moose qw(ArrayRef Bool HashRef Maybe Str Undef);
f49a2a49 4 use SQL::Translator::Types qw(Column Table);
f49a2a49 5
6 has 'table' => (
7 is => 'rw',
8 isa => Table,
9 required => 1,
10 weak_ref => 1,
11 );
4f4fd192 12
13 has 'name' => (
14 is => 'rw',
526e74d1 15 isa => Maybe[Str],
4f4fd192 16 required => 1
17 );
18
19 has 'columns' => (
28bd628e 20 traits => ['Hash'],
4f4fd192 21 is => 'rw',
22 isa => HashRef[Column],
28bd628e 23 handles => {
24 exists_column => 'exists',
25 column_ids => 'keys',
26 get_columns => 'values',
27 get_column => 'get',
28 add_column => 'set',
db2e467f 29
30 ## compat
31 get_fields => 'values',
32 fields => 'keys',
4f4fd192 33 },
34 default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
35 );
36
37 has 'type' => (
38 is => 'rw',
39 isa => Str,
40 required => 1
41 );
526e74d1 42
b750d2f1 43 has 'deferrable' => (
44 is => 'rw',
45 isa => Bool,
075b652f 46 default => 1
b750d2f1 47 );
48
49 has 'expression' => (
50 is => 'rw',
51 isa => Str,
52 );
53
d63c8da0 54 has 'reference_table' => (
55 isa => Maybe[Str],
56 is => 'rw',
57 );
58
59 has 'reference_columns' => (
cb13230a 60 isa => ArrayRef | Undef,
61 is => 'rw',
62 auto_deref => 1
63 );
64
65 has 'match_type' => (
66 isa => Str,
67 is => 'rw'
d63c8da0 68 );
69
51700db2 70 around add_column(Column $column) { $self->$orig($column->name, $column) }
71
6b4be44b 72 method reference_fields { $self->reference_columns }
4f4fd192 73}