line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::DBIC::ExpectedQueries::Query; |
2
|
|
|
|
|
|
|
$Test::DBIC::ExpectedQueries::Query::VERSION = '2.000'; |
3
|
4
|
|
|
4
|
|
68298
|
use Moo; |
|
4
|
|
|
|
|
10964
|
|
|
4
|
|
|
|
|
30
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has sql => ( is => "ro", required => 1 ); |
8
|
|
|
|
|
|
|
has stack_trace => ( is => "ro", required => 1 ); # Just a string |
9
|
|
|
|
|
|
|
has table => ( is => "rw" ); |
10
|
|
|
|
|
|
|
has operation => ( is => "rw" ); |
11
|
|
|
|
|
|
|
|
12
|
48
|
|
|
48
|
0
|
28924
|
sub BUILD { shift->analyze_sql() } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub analyze_sql { |
15
|
48
|
|
|
48
|
0
|
82
|
my $self = shift; |
16
|
48
|
|
|
|
|
89
|
my $sql = $self->sql; |
17
|
|
|
|
|
|
|
|
18
|
48
|
|
|
|
|
158
|
my $table = qr/ |
19
|
|
|
|
|
|
|
[^\w.]* # optional quote |
20
|
|
|
|
|
|
|
([\w.]+) # capture table |
21
|
|
|
|
|
|
|
/x; |
22
|
|
|
|
|
|
|
|
23
|
48
|
100
|
|
|
|
1711
|
if($sql =~ /^ \s* insert\s+ into \s+ $table /ixsm) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
24
|
2
|
|
|
|
|
8
|
$self->table($1); |
25
|
2
|
|
|
|
|
4
|
$self->operation("insert"); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif($sql =~ /^ \s* update\s+ $table /ixsm) { |
28
|
3
|
|
|
|
|
17
|
$self->table($1); |
29
|
3
|
|
|
|
|
11
|
$self->operation("update"); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
elsif($sql =~ /^ \s* delete\s+ from \s+ $table /ixsm) { |
32
|
2
|
|
|
|
|
8
|
$self->table($1); |
33
|
2
|
|
|
|
|
4
|
$self->operation("delete"); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
elsif($sql =~ /^ \s* select\s+ .+? \s? from \s+ $table /ixsm) { |
36
|
4
|
|
|
|
|
27
|
$self->table($1); |
37
|
4
|
|
|
|
|
15
|
$self->operation("select"); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
48
|
|
|
|
|
438
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub display_sql { |
44
|
10
|
|
|
10
|
0
|
15
|
my $self = shift; |
45
|
10
|
|
|
|
|
32
|
return "SQL: (" . $self->sql . ")"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub display_stack_trace { |
49
|
5
|
|
|
5
|
0
|
6
|
my $self = shift; |
50
|
5
|
|
|
|
|
14
|
return " " . $self->stack_trace; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |