line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MySQL::Util::Lite::PrimaryKey; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use Modern::Perl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
6
|
1
|
|
|
1
|
|
131
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
6678
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
8
|
1
|
|
|
1
|
|
77
|
use Method::Signatures; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
9
|
1
|
|
|
1
|
|
389
|
use Data::Printer alias => 'pdump'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
10
|
1
|
|
|
1
|
|
1701
|
use MySQL::Util::Lite::Column; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
114
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'MySQL::Util::Lite::Roles::NewColumn'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has name => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
isa => 'Str', |
17
|
|
|
|
|
|
|
required => 1, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has table_name => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
isa => 'Str', |
23
|
|
|
|
|
|
|
required => 1, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has columns => ( |
27
|
|
|
|
|
|
|
is => 'rw', |
28
|
|
|
|
|
|
|
isa => 'ArrayRef[MySQL::Util::Lite::Column]', |
29
|
|
|
|
|
|
|
lazy => 1, |
30
|
|
|
|
|
|
|
builder => '_build_columns', |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has _util => ( |
34
|
|
|
|
|
|
|
is => 'ro', |
35
|
|
|
|
|
|
|
isa => 'MySQL::Util', |
36
|
|
|
|
|
|
|
required => 1, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
1
|
0
|
|
1
|
|
693
|
method get_columns { |
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return @{ $self->columns }; |
|
0
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 is_autoinc |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Checks if the primary key is a single column and it has autoinc. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Returns: Bool |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
1
|
0
|
|
1
|
|
721
|
method is_autoinc { |
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my @cols = $self->get_columns(); |
55
|
0
|
0
|
|
|
|
|
if ( @cols == 1 ) { |
56
|
0
|
|
|
|
|
|
my $col = shift @cols; |
57
|
0
|
0
|
|
|
|
|
if ( $col->is_autoinc ) { |
58
|
0
|
|
|
|
|
|
return 1; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return 0; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
1
|
0
|
|
1
|
|
826
|
method _build_columns { |
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $aref = $self->_util->get_constraint( |
68
|
|
|
|
|
|
|
table => $self->table_name, |
69
|
|
|
|
|
|
|
name => $self->name |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my @cols; |
73
|
0
|
|
|
|
|
|
foreach my $col (@$aref) { |
74
|
|
|
|
|
|
|
my $href = $self->_util->describe_column( |
75
|
|
|
|
|
|
|
table => $col->{TABLE_NAME}, |
76
|
|
|
|
|
|
|
column => $col->{COLUMN_NAME} |
77
|
0
|
|
|
|
|
|
); |
78
|
0
|
|
|
|
|
|
my $new = $self->new_column($href); |
79
|
0
|
|
|
|
|
|
push @cols, $new; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return \@cols; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |