line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MySQL::Workbench::Parser::Index; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: An index of the ER model |
4
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
87
|
use strict; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
373
|
|
6
|
11
|
|
|
11
|
|
62
|
use warnings; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
365
|
|
7
|
|
|
|
|
|
|
|
8
|
11
|
|
|
11
|
|
61
|
use Moo; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
66
|
|
9
|
11
|
|
|
11
|
|
5119
|
use Scalar::Util qw(blessed); |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
6554
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.10'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has node => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
required => 1, |
17
|
|
|
|
|
|
|
isa => sub { |
18
|
|
|
|
|
|
|
blessed $_[0] && $_[0]->isa( 'XML::LibXML::Element' ); |
19
|
|
|
|
|
|
|
}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has table => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
required => 1, |
25
|
|
|
|
|
|
|
isa => sub { |
26
|
|
|
|
|
|
|
blessed $_[0] && $_[0]->isa( 'MySQL::Workbench::Parser::Table' ); |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub BUILD { |
32
|
51
|
|
|
51
|
1
|
449
|
my $self = shift; |
33
|
51
|
|
|
|
|
136
|
$self->_parse; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has id => ( is => 'rwp' ); |
37
|
|
|
|
|
|
|
has name => ( is => 'rwp' ); |
38
|
|
|
|
|
|
|
has type => ( is => 'rwp' ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has columns => ( |
41
|
|
|
|
|
|
|
is => 'rwp', |
42
|
|
|
|
|
|
|
isa => sub { |
43
|
|
|
|
|
|
|
ref $_[0] && ref $_[0] eq 'ARRAY'; |
44
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
lazy => 1, |
46
|
|
|
|
|
|
|
default => sub { [] }, |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub as_hash { |
51
|
25
|
|
|
25
|
1
|
82
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
25
|
|
|
|
|
42
|
my %info; |
54
|
|
|
|
|
|
|
|
55
|
25
|
|
|
|
|
46
|
for my $attr ( qw(name type columns) ) { |
56
|
75
|
|
|
|
|
589
|
$info{$attr} = $self->$attr(); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
25
|
|
|
|
|
253
|
return \%info; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _parse { |
63
|
51
|
|
|
51
|
|
92
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
51
|
|
|
|
|
136
|
my $node = $self->node; |
66
|
|
|
|
|
|
|
|
67
|
51
|
|
|
|
|
121
|
for my $key ( qw(id) ) { |
68
|
51
|
|
|
|
|
197
|
my $value = $node->findvalue( './value[@key="' . $key . '"]' ); |
69
|
51
|
|
|
|
|
4161
|
my $method = $self->can( '_set_' . $key ); |
70
|
51
|
|
|
|
|
216
|
$self->$method( $value ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
51
|
|
|
|
|
1213
|
my $mapping = $self->table->column_mapping; |
74
|
51
|
|
|
|
|
518
|
my @column_ids = map{ $_->textContent }$node->findnodes( './/link[@key="referencedColumn"]' ); |
|
57
|
|
|
|
|
2488
|
|
75
|
51
|
|
|
|
|
190
|
my @columns = map{ $mapping->{$_} }@column_ids; |
|
57
|
|
|
|
|
930
|
|
76
|
51
|
|
|
|
|
1177
|
$self->_set_columns( \@columns ); |
77
|
|
|
|
|
|
|
|
78
|
51
|
|
|
|
|
441
|
my $name = $node->findvalue( './value[@key="name"]' ); |
79
|
51
|
|
|
|
|
4748
|
$self->_set_name( $name ); |
80
|
|
|
|
|
|
|
|
81
|
51
|
|
|
|
|
142
|
my $type = $node->findvalue( './/value[@key="indexType"]' ); |
82
|
51
|
|
|
|
|
5023
|
$self->_set_type( $type ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |