line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::DBIC::ExpectedQueries::Query; |
2
|
|
|
|
|
|
|
$Test::DBIC::ExpectedQueries::Query::VERSION = '2.001'; |
3
|
5
|
|
|
5
|
|
67451
|
use Moo; |
|
5
|
|
|
|
|
11112
|
|
|
5
|
|
|
|
|
47
|
|
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
|
29718
|
sub BUILD { shift->analyze_sql() } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub analyze_sql { |
15
|
48
|
|
|
48
|
0
|
79
|
my $self = shift; |
16
|
48
|
|
|
|
|
92
|
my $sql = $self->sql; |
17
|
|
|
|
|
|
|
|
18
|
48
|
|
|
|
|
123
|
my $table = qr/ |
19
|
|
|
|
|
|
|
[^\w.]* # optional quote |
20
|
|
|
|
|
|
|
([\w.]+) # capture table |
21
|
|
|
|
|
|
|
/x; |
22
|
|
|
|
|
|
|
|
23
|
48
|
100
|
|
|
|
1641
|
if($sql =~ /^ \s* insert\s+ into \s+ $table /ixsm) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
24
|
2
|
|
|
|
|
9
|
$self->table($1); |
25
|
2
|
|
|
|
|
6
|
$self->operation("insert"); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif($sql =~ /^ \s* update\s+ $table /ixsm) { |
28
|
3
|
|
|
|
|
18
|
$self->table($1); |
29
|
3
|
|
|
|
|
8
|
$self->operation("update"); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
elsif($sql =~ /^ \s* delete\s+ from \s+ $table /ixsm) { |
32
|
2
|
|
|
|
|
7
|
$self->table($1); |
33
|
2
|
|
|
|
|
6
|
$self->operation("delete"); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
elsif($sql =~ /^ \s* select\s+ .+? \s? from \s+ $table /ixsm) { |
36
|
4
|
|
|
|
|
27
|
$self->table($1); |
37
|
4
|
|
|
|
|
11
|
$self->operation("select"); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
48
|
|
|
|
|
449
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub display_sql { |
44
|
10
|
|
|
10
|
0
|
15
|
my $self = shift; |
45
|
10
|
|
|
|
|
36
|
return "SQL: (" . $self->sql . ")"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub display_stack_trace { |
49
|
5
|
|
|
5
|
0
|
8
|
my $self = shift; |
50
|
5
|
|
|
|
|
16
|
return " " . $self->stack_trace; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |