dbMan/Extension/AutoSQL.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 66 CC 6 SCAR 31.7
CC
6
Cov
0%
handle_action
42.0
IDENTIFICATION
2.0
preference
2.0
CRAP 23.8
1 package DBIx::dbMan::Extension::AutoSQL;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.04';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000030-000004"; }
11  
12 sub preference { return 0; }
13  
14 sub known_actions { return [ qw/AUTO_SQL/ ]; }
15  
16 sub handle_action {
17 my ($obj,%action) = @_;
18  
19 if ($action{action} eq 'AUTO_SQL') {
20 $action{action} = 'OUTPUT';
21 $action{output} = '';
22 my $current = $obj->{-dbi}->current;
23 $obj->{-dbi}->set_current($action{connection}); # nic nevypisovat
24 my $asql = $obj->{-dbi}->autosql();
25 my $silent = $obj->{-dbi}->silent_autosql() || 0;
26 if (defined $asql) {
27 if (not ref $asql and $asql eq '-1') {
28 $action{output} = "No current connection.";
29 } else {
30 $asql = [ $asql ] unless ref $asql;
31 if (@$asql) {
32 $obj->{-interface}->add_to_actionlist({ action => 'COMMAND', cmd => 'use %save', output_quiet => 1 });
33 $obj->{-interface}->add_to_actionlist({ action => 'COMMAND', cmd => "use $action{connection}", output_quiet => $silent });
34 for (@$asql) {
35 $obj->{-interface}->add_to_actionlist({ action => 'COMMAND', cmd => $_, output_quiet => $silent });
36 }
37 $obj->{-interface}->add_to_actionlist({ action => 'COMMAND', cmd => 'use %load', output_quiet => 1 });
38 }
39 }
40 }
41 $obj->{-dbi}->set_current($current); # nic nevypisovat
42 }
43  
44 $action{processed} = 1;
45 return %action;
46 }