1SQL::Translator::SchemaU:s:eCronCsotnrtariinbtu(t3e)d PeSrQlL:D:oTcruamnesnltaattoiro:n:Schema::Constraint(3)
2
3
4

NAME

6       SQL::Translator::Schema::Constraint - SQL::Translator constraint object
7

SYNOPSIS

9         use SQL::Translator::Schema::Constraint;
10         my $constraint = SQL::Translator::Schema::Constraint->new(
11             name   => 'foo',
12             fields => [ id ],
13             type   => PRIMARY_KEY,
14         );
15

DESCRIPTION

17       "SQL::Translator::Schema::Constraint" is the constraint object.
18

METHODS

20       new
21
22       Object constructor.
23
24         my $schema           =  SQL::Translator::Schema::Constraint->new(
25             table            => $table,        # table to which it belongs
26             type             => 'foreign_key', # type of table constraint
27             name             => 'fk_phone_id', # name of the constraint
28             fields           => 'phone_id',    # field in the referring table
29             reference_fields => 'phone_id',    # referenced field
30             reference_table  => 'phone',       # referenced table
31             match_type       => 'full',        # how to match
32             on_delete        => 'cascade',     # what to do on deletes
33             on_update        => '',            # what to do on updates
34         );
35
36       deferrable
37
38       Get or set whether the constraint is deferrable.  If not defined, then
39       returns "1."  The argument is evaluated by Perl for True or False, so
40       the following are eqivalent:
41
42         $deferrable = $field->deferrable(0);
43         $deferrable = $field->deferrable('');
44         $deferrable = $field->deferrable('0');
45
46       expression
47
48       Gets and set the expression used in a CHECK constraint.
49
50         my $expression = $constraint->expression('...');
51
52       is_valid
53
54       Determine whether the constraint is valid or not.
55
56         my $ok = $constraint->is_valid;
57
58       fields
59
60       Gets and set the fields the constraint is on.  Accepts a string, list
61       or arrayref; returns an array or array reference.  Will unique the
62       field names and keep them in order by the first occurrence of a field
63       name.
64
65       The fields are returned as Field objects if they exist or as plain
66       names if not. (If you just want the names and want to avoid the Field's
67       overload magic use field_names).
68
69       Returns undef or an empty list if the constraint has no fields set.
70
71         $constraint->fields('id');
72         $constraint->fields('id', 'name');
73         $constraint->fields( 'id, name' );
74         $constraint->fields( [ 'id', 'name' ] );
75         $constraint->fields( qw[ id name ] );
76
77         my @fields = $constraint->fields;
78
79       field_names
80
81       Read-only method to return a list or array ref of the field names.
82       Returns undef or an empty list if the constraint has no fields set.
83       Usefull if you want to avoid the overload magic of the Field objects
84       returned by the fields method.
85
86         my @names = $constraint->field_names;
87
88       match_type
89
90       Get or set the constraint's match_type.  Only valid values are "full"
91       or "partial."
92
93         my $match_type = $constraint->match_type('FULL');
94
95       name
96
97       Get or set the constraint's name.
98
99         my $name = $constraint->name('foo');
100
101       options
102
103       Gets or adds to the constraints's options (e.g., "INITIALLY IMMEDI‐
104       ATE").  Returns an array or array reference.
105
106         $constraint->options('NORELY');
107         my @options = $constraint->options;
108
109       on_delete
110
111       Get or set the constraint's "on delete" action.
112
113         my $action = $constraint->on_delete('cascade');
114
115       on_update
116
117       Get or set the constraint's "on update" action.
118
119         my $action = $constraint->on_update('no action');
120
121       reference_fields
122
123       Gets and set the fields in the referred table.  Accepts a string, list
124       or arrayref; returns an array or array reference.
125
126         $constraint->reference_fields('id');
127         $constraint->reference_fields('id', 'name');
128         $constraint->reference_fields( 'id, name' );
129         $constraint->reference_fields( [ 'id', 'name' ] );
130         $constraint->reference_fields( qw[ id name ] );
131
132         my @reference_fields = $constraint->reference_fields;
133
134       reference_table
135
136       Get or set the table referred to by the constraint.
137
138         my $reference_table = $constraint->reference_table('foo');
139
140       table
141
142       Get or set the constraint's table object.
143
144         my $table = $field->table;
145
146       type
147
148       Get or set the constraint's type.
149
150         my $type = $constraint->type( PRIMARY_KEY );
151
152       equals
153
154       Determines if this constraint is the same as another
155
156         my $isIdentical = $constraint1->equals( $constraint2 );
157

AUTHOR

159       Ken Y. Clark <kclark@cpan.org>.
160
161
162
163perl v5.8.8                       2007-10S-Q2L4::Translator::Schema::Constraint(3)
Impressum