remove ColumnSize and add MatchType
[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);
035b8503 4 use MooseX::MultiMethods;
3c557f72 5 use SQL::Translator::Types qw(Column MatchType Table);
f49a2a49 6
7 has 'table' => (
8 is => 'rw',
9 isa => Table,
f49a2a49 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',
4f4fd192 29 },
30 default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
31 );
32
33 has 'type' => (
34 is => 'rw',
35 isa => Str,
4f4fd192 36 );
526e74d1 37
b750d2f1 38 has 'deferrable' => (
39 is => 'rw',
40 isa => Bool,
075b652f 41 default => 1
b750d2f1 42 );
43
44 has 'expression' => (
45 is => 'rw',
46 isa => Str,
47 );
48
d63c8da0 49 has 'reference_table' => (
50 isa => Maybe[Str],
51 is => 'rw',
52 );
53
54 has 'reference_columns' => (
106f5e00 55 isa => ArrayRef,
56 traits => ['Array'],
57 handles => {
58 reference_columns => 'elements',
59 },
60 default => sub { [] },
cb13230a 61 );
62
63 has 'match_type' => (
3c557f72 64 isa => MatchType,
d191bceb 65 is => 'rw',
3c557f72 66 coerce => 1,
d191bceb 67 lazy => 1,
68 default => ''
d63c8da0 69 );
70
51700db2 71 around add_column(Column $column) { $self->$orig($column->name, $column) }
4f4fd192 72}