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
|
|
83
|
use strict; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
356
|
|
6
|
11
|
|
|
11
|
|
57
|
use warnings; |
|
11
|
|
|
|
|
30
|
|
|
11
|
|
|
|
|
371
|
|
7
|
|
|
|
|
|
|
|
8
|
11
|
|
|
11
|
|
71
|
use Moo; |
|
11
|
|
|
|
|
27
|
|
|
11
|
|
|
|
|
69
|
|
9
|
11
|
|
|
11
|
|
3679
|
use Scalar::Util qw(blessed); |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
6981
|
|
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
|
452
|
my $self = shift; |
33
|
51
|
|
|
|
|
140
|
$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
|
83
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
25
|
|
|
|
|
39
|
my %info; |
54
|
|
|
|
|
|
|
|
55
|
25
|
|
|
|
|
49
|
for my $attr ( qw(name type columns) ) { |
56
|
75
|
|
|
|
|
603
|
$info{$attr} = $self->$attr(); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
25
|
|
|
|
|
255
|
return \%info; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _parse { |
63
|
51
|
|
|
51
|
|
91
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
51
|
|
|
|
|
136
|
my $node = $self->node; |
66
|
|
|
|
|
|
|
|
67
|
51
|
|
|
|
|
135
|
for my $key ( qw(id) ) { |
68
|
51
|
|
|
|
|
206
|
my $value = $node->findvalue( './value[@key="' . $key . '"]' ); |
69
|
51
|
|
|
|
|
4049
|
my $method = $self->can( '_set_' . $key ); |
70
|
51
|
|
|
|
|
220
|
$self->$method( $value ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
51
|
|
|
|
|
1213
|
my $mapping = $self->table->column_mapping; |
74
|
51
|
|
|
|
|
495
|
my @column_ids = map{ $_->textContent }$node->findnodes( './/link[@key="referencedColumn"]' ); |
|
57
|
|
|
|
|
2410
|
|
75
|
51
|
|
|
|
|
174
|
my @columns = map{ $mapping->{$_} }@column_ids; |
|
57
|
|
|
|
|
863
|
|
76
|
51
|
|
|
|
|
1141
|
$self->_set_columns( \@columns ); |
77
|
|
|
|
|
|
|
|
78
|
51
|
|
|
|
|
425
|
my $name = $node->findvalue( './value[@key="name"]' ); |
79
|
51
|
|
|
|
|
4950
|
$self->_set_name( $name ); |
80
|
|
|
|
|
|
|
|
81
|
51
|
|
|
|
|
131
|
my $type = $node->findvalue( './/value[@key="indexType"]' ); |
82
|
51
|
|
|
|
|
5084
|
$self->_set_type( $type ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |