dbMan/Extension/SuggestionCacheRetrieve.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 102 CC 11 SCAR 45.1
CC
11
Cov
0%
handle_action
132.0
IDENTIFICATION
2.0
preference
2.0
CRAP 91.4
1 package DBIx::dbMan::Extension::SuggestionCacheRetrieve;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.01';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000098-000001"; }
11  
12 sub preference { return 6000; }
13  
14 sub known_actions { return [ qw/SQL DESCRIBE/ ]; }
15  
16 sub handle_action {
17 my ($obj,%action) = @_;
18  
19 $action{processed} = 1;
20  
21 if ($action{action} eq 'SQL' && $action{oper} eq 'complete' and $action{what} eq 'list') {
22 my $local_mempool = $obj->{-dbi}->mempool();
23  
24 my $cache_type = '';
25 if ( $obj->{-dbi}->driver eq 'Oracle' ) {
26 if ($action{context} =~ /\./) {
27 $cache_type = 'sql_oracle_' . $action{type} . '___' . $action{context};
28 } else {
29 $cache_type = 'sql_oracle_' . $action{type};
30 }
31 } else {
32 my $type = $action{type};
33 $type = 'object' if lc $action{type} eq 'context';
34 $cache_type = 'sql_type_' . lc( $type );
35 }
36  
37 if ( $local_mempool and $local_mempool->get( 'suggestion_cache' ) ) {
38 my $list = $local_mempool->get('suggestion_cache_content:' . $cache_type);
39 if ( $list ) {
40 $action{list} = [ @$list ]; # do copy (for sure)
41 $action{processed} = 1;
42 $action{action} = 'NONE';
43 }
44 }
45 } elsif ($action{action} eq 'DESCRIBE' && $action{oper} eq 'complete' and $action{what} eq 'list') {
46 my $local_mempool = $obj->{-dbi}->mempool();
47  
48 my $cache_type = '';
49 if ( $obj->{-dbi}->driver eq 'Oracle' ) {
50 $cache_type = 'describe_ora';
51 } else {
52 $cache_type = 'describe_std';
53 }
54  
55 if ( $local_mempool and $local_mempool->get( 'suggestion_cache' ) ) {
56 my $list = $local_mempool->get('suggestion_cache_content:' . $cache_type);
57 if ( $list ) {
58 $action{list} = [ @$list ]; # do copy (for sure)
59 $action{processed} = 1;
60 $action{action} = 'NONE';
61 }
62 }
63 }
64  
65 return %action;
66 }