line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rose::DB::Object::Metadata::UniqueKey; |
2
|
|
|
|
|
|
|
|
3
|
61
|
|
|
61
|
|
497
|
use strict; |
|
61
|
|
|
|
|
167
|
|
|
61
|
|
|
|
|
2343
|
|
4
|
|
|
|
|
|
|
|
5
|
61
|
|
|
61
|
|
1318
|
use Rose::DB::Object::Metadata::Util qw(perl_quote_value); |
|
61
|
|
|
|
|
144
|
|
|
61
|
|
|
|
|
4247
|
|
6
|
|
|
|
|
|
|
|
7
|
61
|
|
|
61
|
|
27363
|
use Rose::DB::Object::Metadata::ColumnList; |
|
61
|
|
|
|
|
220
|
|
|
61
|
|
|
|
|
4141
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Rose::DB::Object::Metadata::ColumnList); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.782'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Rose::Object::MakeMethods::Generic |
13
|
|
|
|
|
|
|
( |
14
|
61
|
|
|
|
|
544
|
'scalar --get_set_init' => |
15
|
|
|
|
|
|
|
[ |
16
|
|
|
|
|
|
|
'name' |
17
|
|
|
|
|
|
|
], |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
boolean => 'has_predicate', |
20
|
61
|
|
|
61
|
|
639
|
); |
|
61
|
|
|
|
|
158
|
|
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
0
|
0
|
|
sub init_name { join('_', shift->column_names) || undef } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub perl_array_definition |
25
|
|
|
|
|
|
|
{ |
26
|
0
|
|
|
0
|
0
|
|
'[ ' . join(', ', map { perl_quote_value($_) } shift->column_names) . ' ]' |
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub perl_object_definition |
30
|
|
|
|
|
|
|
{ |
31
|
0
|
|
|
0
|
0
|
|
my($self) = shift; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
return ref($self) . '->new(name => ' . perl_quote_value($self->name) . |
34
|
|
|
|
|
|
|
', columns => [ ' . |
35
|
0
|
|
|
|
|
|
join(', ', map { perl_quote_value($_) } $self->column_names) . ' ])'; |
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Rose::DB::Object::Metadata::UniqueKey - Unique key metadata. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
use Rose::DB::Object::Metadata::UniqueKey; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$uk = Rose::DB::Object::Metadata::UniqueKey->new( |
51
|
|
|
|
|
|
|
columns => [ 'name', 'color' ]); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
MyClass->meta->add_unique_key($uk); |
54
|
|
|
|
|
|
|
... |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Objects of this class store and manipulate metadata for unique keys in a database table. Each unique key is made up of one or more columns. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=over 4 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item B<add_column [COLUMNS]> |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This method is an alias for the L<add_columns|/add_columns> method. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item B<add_columns [COLUMNS]> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Add COLUMNS to the list of columns that make up the unique key. COLUMNS must be a list or reference to an array of column names or L<Rose::DB::Object::Metadata::Column>-derived objects. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item B<columns [COLUMNS]> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Get or set the list of columns that make up the unique key. COLUMNS must a list or reference to an array of column names or L<Rose::DB::Object::Metadata::Column>-derived objects. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This method returns all of the columns that make up the unique key. Each column is a L<Rose::DB::Object::Metadata::Column>-derived column object if the unique key's L<parent|/parent> has a column object with the same name, or just the column name otherwise. In scalar context, a reference to an array of columns is returned. In list context, a list is returned. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item B<column_names> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns a list (in list context) or reference to an array (in scalar context) of the names of the columns that make up the unique key. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item B<delete_columns> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Delete the entire list of columns that make up the unique key. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item B<name [NAME]> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Get or set the name of the unique key. This name should be unique among all unique keys for a given table. Traditionally, it is the name of the index that the database uses to maintain the unique key, but practices vary. If left undefined, the default value is a string created by joining the L<column_names|/column_names> with underscores. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item B<parent [META]> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Get or set the L<Rose::DB::Object::Metadata>-derived object that this unique key belongs to. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 LICENSE |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is |
103
|
|
|
|
|
|
|
free software; you can redistribute it and/or modify it under the same terms |
104
|
|
|
|
|
|
|
as Perl itself. |