line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SQL::DB::Iter; |
2
|
5
|
|
|
5
|
|
26762
|
use Moo; |
|
5
|
|
|
|
|
16797
|
|
|
5
|
|
|
|
|
54
|
|
3
|
5
|
|
|
5
|
|
4737
|
use Sub::Install qw/install_sub/; |
|
5
|
|
|
|
|
2724
|
|
|
5
|
|
|
|
|
41
|
|
4
|
5
|
|
|
5
|
|
541
|
use Carp qw(croak); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
5018
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.971.0'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'sth' => ( |
9
|
|
|
|
|
|
|
is => 'ro', |
10
|
|
|
|
|
|
|
required => 1, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'class' => ( |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
writer => '_class', |
16
|
|
|
|
|
|
|
init_arg => undef, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# '_done' is a bool set to true when there are no more rows to |
20
|
|
|
|
|
|
|
# be returned. |
21
|
|
|
|
|
|
|
has '_done' => ( |
22
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
init_arg => undef, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my %classes; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub BUILD { |
29
|
11
|
|
|
11
|
1
|
3117
|
my $self = shift; |
30
|
11
|
50
|
|
|
|
64
|
return if $self->class; |
31
|
|
|
|
|
|
|
|
32
|
11
|
|
|
|
|
125
|
my @cols = map { $_ =~ s/\s+/_/g; $_ } @{ $self->sth->{NAME_lc} }; |
|
25
|
|
|
|
|
73
|
|
|
25
|
|
|
|
|
71
|
|
|
11
|
|
|
|
|
214
|
|
33
|
11
|
|
|
|
|
66
|
my $class = 'SQL::DB::Row::' . join( '_', @cols ); |
34
|
|
|
|
|
|
|
|
35
|
11
|
100
|
|
|
|
55
|
if ( !$classes{$class} ) { |
36
|
3
|
|
|
|
|
8
|
my $i = 0; |
37
|
3
|
|
|
|
|
154
|
my $x = eval $i; |
38
|
3
|
|
|
|
|
20
|
foreach my $col (@cols) { |
39
|
8
|
|
|
|
|
488
|
my $x = eval $i; |
40
|
|
|
|
|
|
|
install_sub( |
41
|
|
|
|
|
|
|
{ |
42
|
|
|
|
|
|
|
code => sub { |
43
|
18
|
50
|
|
18
|
|
2005
|
$_[0]->[$x] = $_[2] if @_ == 2; |
44
|
18
|
|
|
|
|
107
|
return $_[0]->[$x]; |
45
|
|
|
|
|
|
|
}, |
46
|
8
|
|
|
|
|
104
|
into => $class, |
47
|
|
|
|
|
|
|
as => $col, |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
); |
50
|
8
|
|
|
|
|
696
|
$i++; |
51
|
|
|
|
|
|
|
} |
52
|
3
|
|
|
|
|
13
|
$classes{$class} = 1; |
53
|
|
|
|
|
|
|
} |
54
|
11
|
|
|
|
|
1436
|
$self->class($class); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub next { |
58
|
11
|
|
|
11
|
1
|
33
|
my $self = shift; |
59
|
11
|
|
|
|
|
39
|
return $self->object; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub all { |
63
|
4
|
|
|
4
|
1
|
8
|
my $self = shift; |
64
|
4
|
|
|
|
|
21
|
return $self->objects; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub object { |
68
|
11
|
|
|
11
|
1
|
21
|
my $self = shift; |
69
|
11
|
100
|
|
|
|
62
|
return if ( $self->_done ); |
70
|
|
|
|
|
|
|
|
71
|
9
|
|
|
|
|
275
|
my @values = $self->sth->fetchrow_array; |
72
|
|
|
|
|
|
|
|
73
|
9
|
100
|
|
|
|
220
|
if ( !@values ) { |
74
|
2
|
|
|
|
|
9
|
$self->finish; |
75
|
2
|
|
|
|
|
10
|
return; |
76
|
|
|
|
|
|
|
} |
77
|
7
|
|
|
|
|
75
|
return bless \@values, $self->class; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub objects { |
81
|
4
|
|
|
4
|
1
|
8
|
my $self = shift; |
82
|
4
|
|
|
|
|
16
|
my $all = $self->arrays; |
83
|
|
|
|
|
|
|
|
84
|
4
|
|
|
|
|
11
|
my $class = $self->class; |
85
|
|
|
|
|
|
|
|
86
|
4
|
|
|
|
|
10
|
foreach ( 0 .. $#{$all} ) { |
|
4
|
|
|
|
|
16
|
|
87
|
11
|
|
|
|
|
49
|
bless $all->[$_], $class; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
4
|
|
|
|
|
12
|
$self->finish; |
91
|
4
|
50
|
|
|
|
37
|
return @$all if wantarray; |
92
|
0
|
|
|
|
|
0
|
return $all; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub hash { |
96
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
97
|
0
|
0
|
|
|
|
0
|
return if ( $self->_done ); |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
0
|
my $ref = $self->sth->fetchrow_hashref('NAME_lc'); |
100
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
|
|
0
|
if ( !$ref ) { |
102
|
0
|
|
|
|
|
0
|
$self->finish; |
103
|
0
|
|
|
|
|
0
|
return; |
104
|
|
|
|
|
|
|
} |
105
|
0
|
|
|
|
|
0
|
return $ref; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub hashes { |
109
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
110
|
0
|
|
|
|
|
0
|
my @all; |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
0
|
while ( my $ref = $self->sth->fetchrow_hashref('NAME_lc') ) { |
113
|
0
|
|
|
|
|
0
|
push( @all, $ref ); |
114
|
|
|
|
|
|
|
} |
115
|
0
|
|
|
|
|
0
|
$self->finish; |
116
|
0
|
0
|
|
|
|
0
|
return @all if wantarray; |
117
|
0
|
|
|
|
|
0
|
return \@all; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub array { |
121
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
122
|
0
|
0
|
|
|
|
0
|
return if ( $self->_done ); |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
0
|
my $ref = $self->sth->fetchrow_arrayref; |
125
|
|
|
|
|
|
|
|
126
|
0
|
0
|
|
|
|
0
|
if ( !$ref ) { |
127
|
0
|
|
|
|
|
0
|
$self->finish; |
128
|
0
|
|
|
|
|
0
|
return; |
129
|
|
|
|
|
|
|
} |
130
|
0
|
|
|
|
|
0
|
return $ref; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub arrays { |
134
|
4
|
|
|
4
|
1
|
7
|
my $self = shift; |
135
|
|
|
|
|
|
|
|
136
|
4
|
|
|
|
|
141
|
my $all = $self->sth->fetchall_arrayref; |
137
|
4
|
|
|
|
|
13
|
$self->finish; |
138
|
4
|
50
|
|
|
|
12
|
return @$all if wantarray; |
139
|
4
|
|
|
|
|
9
|
return $all; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub finish { |
143
|
26
|
|
|
26
|
1
|
35
|
my $self = shift; |
144
|
26
|
100
|
|
|
|
128
|
return if $self->_done; |
145
|
11
|
|
|
|
|
69
|
$self->sth->finish; |
146
|
11
|
|
|
|
|
41
|
$self->_done(1); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub DESTROY { |
150
|
11
|
|
|
11
|
|
1196
|
my $self = shift; |
151
|
11
|
|
|
|
|
32
|
$self->finish; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
1; |