line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geoffrey::Role::Action; |
2
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
107020
|
use utf8; |
|
20
|
|
|
|
|
69
|
|
|
20
|
|
|
|
|
105
|
|
4
|
20
|
|
|
20
|
|
622
|
use strict; |
|
20
|
|
|
|
|
41
|
|
|
20
|
|
|
|
|
458
|
|
5
|
20
|
|
|
20
|
|
121
|
use warnings FATAL => 'all'; |
|
20
|
|
|
|
|
40
|
|
|
20
|
|
|
|
|
14921
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$Geoffrey::Role::Action::VERSION = '0.000204'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
184
|
|
|
184
|
1
|
3282
|
my $class = shift; |
11
|
184
|
|
|
|
|
606
|
my $self = {@_}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# make converter required |
14
|
184
|
100
|
|
|
|
583
|
if ( !$self->{converter} ) { |
15
|
1
|
|
|
|
|
6
|
require Geoffrey::Exception::RequiredValue; |
16
|
1
|
|
|
|
|
4
|
Geoffrey::Exception::RequiredValue::throw_converter( __PACKAGE__ . '::new' ); |
17
|
|
|
|
|
|
|
} |
18
|
183
|
|
|
|
|
852
|
return bless $self, $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
190
|
|
|
190
|
1
|
1161
|
sub dbh { return $_[0]->{dbh} } |
22
|
|
|
|
|
|
|
|
23
|
575
|
|
|
575
|
1
|
2359
|
sub converter { return $_[0]->{converter} } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub add { |
26
|
1
|
|
|
1
|
1
|
58
|
require Geoffrey::Exception::NotSupportedException; |
27
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_action( 'add', shift ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub alter { |
31
|
9
|
|
|
9
|
1
|
6090
|
require Geoffrey::Exception::NotSupportedException; |
32
|
9
|
|
|
|
|
60
|
return Geoffrey::Exception::NotSupportedException::throw_action( 'alter', shift ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub drop { |
36
|
4
|
|
|
4
|
1
|
3342
|
require Geoffrey::Exception::NotSupportedException; |
37
|
4
|
|
|
|
|
21
|
return Geoffrey::Exception::NotSupportedException::throw_action( 'drop', shift ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub list_from_schema { |
41
|
2
|
|
|
2
|
1
|
1601
|
require Geoffrey::Exception::NotSupportedException; |
42
|
2
|
|
|
|
|
9
|
return Geoffrey::Exception::NotSupportedException::throw_action( 'list_from_schema', shift ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub dryrun { |
46
|
127
|
|
|
127
|
1
|
5724
|
my ( $self, $dryrun ) = @_; |
47
|
127
|
100
|
|
|
|
648
|
return $self->{dryrun} if !defined $dryrun; |
48
|
44
|
|
|
|
|
140
|
$self->{dryrun} = $dryrun; |
49
|
44
|
|
|
|
|
157
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub for_table { |
53
|
434
|
|
|
434
|
1
|
716
|
my ( $self, $for_table ) = @_; |
54
|
434
|
100
|
|
|
|
1143
|
return $self->{for_table} if !defined $for_table; |
55
|
323
|
|
|
|
|
487
|
$self->{for_table} = $for_table; |
56
|
323
|
|
|
|
|
651
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub do { |
60
|
45
|
|
|
45
|
1
|
143
|
my ( $self, $s_sql ) = @_; |
61
|
45
|
100
|
|
|
|
183
|
return $s_sql if $self->dryrun; |
62
|
30
|
|
|
|
|
4979
|
require Geoffrey::Exception::Database; |
63
|
30
|
100
|
|
|
|
191
|
Geoffrey::Exception::Database::throw_no_dbh() if !$self->dbh; |
64
|
29
|
100
|
|
|
|
85
|
$self->dbh->do($s_sql) or Geoffrey::Exception::Database::throw_sql_handle( $!, $s_sql ); |
65
|
26
|
|
|
|
|
292054
|
return $s_sql; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub do_arrayref { |
69
|
17
|
|
|
17
|
1
|
490
|
my ( $self, $s_sql, $options ) = @_; |
70
|
17
|
50
|
|
|
|
65
|
return unless $s_sql; |
71
|
17
|
100
|
|
|
|
73
|
return [] if $self->dryrun; |
72
|
14
|
|
|
|
|
1515
|
require Geoffrey::Exception::Database; |
73
|
14
|
50
|
|
|
|
87
|
Geoffrey::Exception::Database::throw_no_dbh() if !$self->dbh; |
74
|
14
|
|
66
|
|
|
81
|
return $self->dbh->selectall_arrayref( $s_sql, { Slice => {} }, @{$options} ) |
75
|
|
|
|
|
|
|
|| Geoffrey::Exception::Database::throw_sql_handle( $!, $s_sql ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub do_prepared { |
79
|
9
|
|
|
9
|
1
|
33
|
my ( $self, $s_sql, $ar_values ) = @_; |
80
|
9
|
100
|
|
|
|
35
|
return $s_sql if $self->dryrun; |
81
|
8
|
|
|
|
|
50
|
require Carp; |
82
|
8
|
50
|
|
|
|
33
|
my $obj_prepared_statement = $self->dbh->prepare($s_sql) or Carp::longmess( $!, $s_sql ); |
83
|
8
|
50
|
|
|
|
1200
|
$obj_prepared_statement->execute( @{$ar_values} ) or Carp::longmess( $!, $s_sql ); |
|
8
|
|
|
|
|
85712
|
|
84
|
8
|
|
|
|
|
469
|
return $s_sql; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; # End of Geoffrey::Role::Action |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |