line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geoffrey::Role::Action; |
2
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
102516
|
use utf8; |
|
20
|
|
|
|
|
67
|
|
|
20
|
|
|
|
|
112
|
|
4
|
20
|
|
|
20
|
|
610
|
use strict; |
|
20
|
|
|
|
|
52
|
|
|
20
|
|
|
|
|
456
|
|
5
|
20
|
|
|
20
|
|
117
|
use warnings FATAL => 'all'; |
|
20
|
|
|
|
|
37
|
|
|
20
|
|
|
|
|
16091
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$Geoffrey::Role::Action::VERSION = '0.000205'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
184
|
|
|
184
|
1
|
3118
|
my $class = shift; |
11
|
184
|
|
|
|
|
541
|
my $self = {@_}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# make converter required |
14
|
184
|
100
|
|
|
|
540
|
if ( !$self->{converter} ) { |
15
|
1
|
|
|
|
|
5
|
require Geoffrey::Exception::RequiredValue; |
16
|
1
|
|
|
|
|
6
|
Geoffrey::Exception::RequiredValue::throw_converter( __PACKAGE__ . '::new' ); |
17
|
|
|
|
|
|
|
} |
18
|
183
|
|
|
|
|
822
|
return bless $self, $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
198
|
|
|
198
|
1
|
2125
|
sub dbh { return $_[0]->{dbh} } |
22
|
|
|
|
|
|
|
|
23
|
575
|
|
|
575
|
1
|
2061
|
sub converter { return $_[0]->{converter} } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub add { |
26
|
1
|
|
|
1
|
1
|
94
|
require Geoffrey::Exception::NotSupportedException; |
27
|
1
|
|
|
|
|
6
|
return Geoffrey::Exception::NotSupportedException::throw_action( 'add', shift ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub alter { |
31
|
9
|
|
|
9
|
1
|
6051
|
require Geoffrey::Exception::NotSupportedException; |
32
|
9
|
|
|
|
|
45
|
return Geoffrey::Exception::NotSupportedException::throw_action( 'alter', shift ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub drop { |
36
|
4
|
|
|
4
|
1
|
3258
|
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
|
1622
|
require Geoffrey::Exception::NotSupportedException; |
42
|
2
|
|
|
|
|
11
|
return Geoffrey::Exception::NotSupportedException::throw_action( 'list_from_schema', shift ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub dryrun { |
46
|
127
|
|
|
127
|
1
|
5158
|
my ( $self, $dryrun ) = @_; |
47
|
127
|
100
|
|
|
|
616
|
return $self->{dryrun} if !defined $dryrun; |
48
|
44
|
|
|
|
|
100
|
$self->{dryrun} = $dryrun; |
49
|
44
|
|
|
|
|
161
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub for_table { |
53
|
434
|
|
|
434
|
1
|
719
|
my ( $self, $for_table ) = @_; |
54
|
434
|
100
|
|
|
|
1150
|
return $self->{for_table} if !defined $for_table; |
55
|
323
|
|
|
|
|
476
|
$self->{for_table} = $for_table; |
56
|
323
|
|
|
|
|
649
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub do { |
60
|
45
|
|
|
45
|
1
|
136
|
my ( $self, $s_sql ) = @_; |
61
|
45
|
100
|
|
|
|
193
|
return $s_sql if $self->dryrun; |
62
|
30
|
|
|
|
|
5136
|
require Geoffrey::Exception::Database; |
63
|
30
|
100
|
|
|
|
165
|
Geoffrey::Exception::Database::throw_no_dbh() if !$self->dbh; |
64
|
29
|
100
|
|
|
|
78
|
$self->dbh->do($s_sql) || Geoffrey::Exception::Database::throw_sql_handle( $self->dbh->errstr . "\n" . $self->dbh->err . "\n" . $!, $s_sql ); |
65
|
26
|
|
|
|
|
354399
|
return $s_sql; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub do_arrayref { |
69
|
17
|
|
|
17
|
1
|
545
|
my ( $self, $s_sql, $options ) = @_; |
70
|
17
|
50
|
|
|
|
49
|
return unless $s_sql; |
71
|
17
|
100
|
|
|
|
65
|
return [] if $self->dryrun; |
72
|
14
|
|
|
|
|
1522
|
require Geoffrey::Exception::Database; |
73
|
14
|
50
|
|
|
|
82
|
Geoffrey::Exception::Database::throw_no_dbh() if !$self->dbh; |
74
|
14
|
|
66
|
|
|
61
|
return $self->dbh->selectall_arrayref( $s_sql, { Slice => {} }, @{$options} ) |
75
|
|
|
|
|
|
|
|| Geoffrey::Exception::Database::throw_sql_handle( $self->dbh->errstr . "\n" . $self->dbh->err . "\n" . $!, $s_sql ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub do_prepared { |
79
|
9
|
|
|
9
|
1
|
29
|
my ( $self, $s_sql, $ar_values ) = @_; |
80
|
9
|
100
|
|
|
|
29
|
return $s_sql if $self->dryrun; |
81
|
8
|
|
|
|
|
49
|
require Carp; |
82
|
8
|
50
|
|
|
|
39
|
my $obj_prepared_statement = $self->dbh->prepare($s_sql) or Carp::longmess( $!, $s_sql ); |
83
|
8
|
50
|
|
|
|
1140
|
$obj_prepared_statement->execute( @{$ar_values} ) or Carp::longmess( $!, $s_sql ); |
|
8
|
|
|
|
|
79642
|
|
84
|
8
|
|
|
|
|
266
|
return $s_sql; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; # End of Geoffrey::Role::Action |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |