line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MySQL::Util::Lite::PrimaryKey; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use Modern::Perl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
145
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
5568
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
8
|
1
|
|
|
1
|
|
54
|
use Method::Signatures; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
9
|
1
|
|
|
1
|
|
404
|
use Data::Printer alias => 'pdump'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
10
|
1
|
|
|
1
|
|
1767
|
use MySQL::Util::Lite::Column; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
83
|
|
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
|
|
700
|
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
|
|
629
|
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
|
|
660
|
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; |