line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package SQL::Admin::Catalog::Table; |
3
|
2
|
|
|
2
|
|
1172
|
use base qw( SQL::Admin::Catalog::Object ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
152
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
50
|
|
6
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1290
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = v0.5.0; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
###################################################################### |
11
|
|
|
|
|
|
|
###################################################################### |
12
|
|
|
|
|
|
|
sub add { # ; |
13
|
9
|
|
|
9
|
0
|
29
|
my ($self, $what, @params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
9
|
50
|
|
|
|
30
|
return unless $self->catalog; |
16
|
|
|
|
|
|
|
|
17
|
9
|
50
|
|
|
|
27
|
return $self->table_row (@params) |
18
|
|
|
|
|
|
|
if $what eq 'table_row'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
################################################################## |
21
|
|
|
|
|
|
|
|
22
|
9
|
|
|
|
|
26
|
my $obj = $self->catalog->add ($what, table => $self, @params); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
################################################################## |
25
|
|
|
|
|
|
|
|
26
|
9
|
100
|
|
|
|
43
|
return $self->column ($obj->name, $obj) |
27
|
|
|
|
|
|
|
if $what eq 'column'; |
28
|
|
|
|
|
|
|
|
29
|
4
|
100
|
|
|
|
18
|
return $self->primary_key ($obj) |
30
|
|
|
|
|
|
|
if $what eq 'primary_key'; |
31
|
|
|
|
|
|
|
|
32
|
2
|
100
|
|
|
|
10
|
return $self->unique ($obj->fullname, $obj) |
33
|
|
|
|
|
|
|
if $what eq 'unique'; |
34
|
|
|
|
|
|
|
|
35
|
1
|
50
|
|
|
|
7
|
return $self->foreign_key ($obj->fullname, $obj) |
36
|
|
|
|
|
|
|
if $what eq 'foreign_key'; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
###################################################################### |
42
|
|
|
|
|
|
|
###################################################################### |
43
|
|
|
|
|
|
|
sub column { # ; |
44
|
6
|
|
|
6
|
0
|
9
|
my $self = shift; |
45
|
6
|
|
100
|
|
|
25
|
my $map = $self->{column_map} ||= {}; |
46
|
|
|
|
|
|
|
|
47
|
6
|
100
|
|
|
|
25
|
return $map unless @_; |
48
|
|
|
|
|
|
|
|
49
|
5
|
|
|
|
|
10
|
my $name = shift; |
50
|
5
|
50
|
|
|
|
11
|
return unless defined $name; |
51
|
|
|
|
|
|
|
|
52
|
5
|
50
|
|
|
|
15
|
return $map->{$name} unless @_; |
53
|
|
|
|
|
|
|
|
54
|
5
|
|
|
|
|
6
|
my $col = shift; |
55
|
5
|
|
100
|
|
|
18
|
my $list = $self->{column_list} ||= []; |
56
|
|
|
|
|
|
|
|
57
|
5
|
50
|
|
|
|
23
|
push @$list, $col->name |
58
|
|
|
|
|
|
|
unless exists $map->{$name}; |
59
|
|
|
|
|
|
|
|
60
|
5
|
|
|
|
|
32
|
$map->{$name} = $col; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
###################################################################### |
65
|
|
|
|
|
|
|
###################################################################### |
66
|
|
|
|
|
|
|
sub columns { # ; |
67
|
0
|
|
0
|
0
|
0
|
0
|
my $retval = shift->{column_list} ||= []; |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
0
|
return $retval unless wantarray; |
70
|
0
|
|
|
|
|
0
|
return @$retval; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
###################################################################### |
75
|
|
|
|
|
|
|
###################################################################### |
76
|
|
|
|
|
|
|
sub option { # ; |
77
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
78
|
0
|
0
|
0
|
|
|
0
|
return $self->{option} ||= {} unless @_; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
my $key = shift; |
81
|
0
|
0
|
|
|
|
0
|
return $self->{option}{ $key } unless @_; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
0
|
$self->{option}{$key} = shift; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
###################################################################### |
88
|
|
|
|
|
|
|
###################################################################### |
89
|
|
|
|
|
|
|
sub primary_key { # ; |
90
|
6
|
|
|
6
|
0
|
954
|
my $self = shift; |
91
|
|
|
|
|
|
|
|
92
|
6
|
100
|
|
|
|
18
|
$self->{primary_key} = shift if @_; |
93
|
6
|
|
|
|
|
31
|
$self->{primary_key}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
###################################################################### |
98
|
|
|
|
|
|
|
###################################################################### |
99
|
|
|
|
|
|
|
sub unique { # ; |
100
|
3
|
|
|
3
|
0
|
604
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
3
|
|
100
|
|
|
18
|
my $map = $self->{unique} ||= {}; |
103
|
3
|
100
|
|
|
|
14
|
return $map unless @_; |
104
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
2
|
my $key = shift; |
106
|
1
|
50
|
|
|
|
4
|
return $map->{$key} unless @_; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
10
|
$map->{$key} = shift; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
###################################################################### |
113
|
|
|
|
|
|
|
###################################################################### |
114
|
|
|
|
|
|
|
sub foreign_key { # ; |
115
|
3
|
|
|
3
|
0
|
654
|
my $self = shift; |
116
|
|
|
|
|
|
|
|
117
|
3
|
|
100
|
|
|
23
|
my $map = $self->{foreign_key} ||= {}; |
118
|
3
|
100
|
|
|
|
15
|
return $map unless @_; |
119
|
|
|
|
|
|
|
|
120
|
1
|
|
|
|
|
2
|
my $key = shift; |
121
|
1
|
50
|
|
|
|
3
|
return $map->{$key} unless @_; |
122
|
|
|
|
|
|
|
|
123
|
1
|
|
|
|
|
10
|
$map->{$key} = shift; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
###################################################################### |
128
|
|
|
|
|
|
|
###################################################################### |
129
|
|
|
|
|
|
|
sub table_row { # ; |
130
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
0
|
|
|
|
my $list = $self->{table_row} ||= []; |
133
|
0
|
0
|
|
|
|
|
return $list unless @_; |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
push @$list, @_; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
###################################################################### |
140
|
|
|
|
|
|
|
###################################################################### |
141
|
|
|
|
|
|
|
sub set_row_search { # ; |
142
|
0
|
|
|
0
|
0
|
|
my $self= shift; |
143
|
0
|
|
|
|
|
|
$self->{row_search} = shift; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
###################################################################### |
148
|
|
|
|
|
|
|
###################################################################### |
149
|
|
|
|
|
|
|
sub row_search { # ; |
150
|
|
|
|
|
|
|
# simple query, just key-value pair |
151
|
0
|
|
|
0
|
0
|
|
my ($self, $query) = @_; |
152
|
|
|
|
|
|
|
|
153
|
0
|
0
|
|
|
|
|
return $self->{row_search}->($self, $query) |
154
|
|
|
|
|
|
|
if $self->{row_search}; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
###################################################################### |
160
|
|
|
|
|
|
|
###################################################################### |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
package SQL::Admin::Catalog::Table; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |
165
|
|
|
|
|
|
|
|