line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Database::Handle; |
2
|
|
|
|
|
|
|
$Test::Database::Handle::VERSION = '1.113'; |
3
|
9
|
|
|
9
|
|
73867
|
use strict; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
348
|
|
4
|
9
|
|
|
9
|
|
49
|
use warnings; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
251
|
|
5
|
9
|
|
|
9
|
|
48
|
use Carp; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
640
|
|
6
|
9
|
|
|
9
|
|
13115
|
use DBI; |
|
9
|
|
|
|
|
115943
|
|
|
9
|
|
|
|
|
655
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# basic accessors |
9
|
|
|
|
|
|
|
for my $attr (qw( dbd dsn username password name driver )) { |
10
|
9
|
|
|
9
|
|
80
|
no strict 'refs'; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
3190
|
|
11
|
200
|
|
|
200
|
|
4744
|
*{$attr} = sub { return $_[0]{$attr} }; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
13
|
|
|
13
|
1
|
651317
|
my ( $class, %args ) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
exists $args{$_} or croak "$_ argument required" |
18
|
13
|
|
66
|
|
|
423
|
for qw( dsn ); |
19
|
|
|
|
|
|
|
|
20
|
11
|
|
|
|
|
133
|
my ( $scheme, $driver, $attr_string, $attr_hash, $driver_dsn ) |
21
|
|
|
|
|
|
|
= DBI->parse_dsn( $args{dsn} ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# fix args |
24
|
11
|
|
|
|
|
397
|
%args = ( |
25
|
|
|
|
|
|
|
%args, |
26
|
|
|
|
|
|
|
dbd => $driver, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# try to provide a Test::Database::Driver object |
30
|
11
|
100
|
|
|
|
60
|
if ( !exists $args{driver} ) { |
31
|
8
|
|
|
|
|
12
|
eval { |
32
|
8
|
|
|
|
|
160
|
$args{driver} = "Test::Database::Driver::$driver"->new( |
33
|
|
|
|
|
|
|
driver_dsn => $args{dsn}, |
34
|
|
|
|
|
|
|
username => $args{username}, |
35
|
|
|
|
|
|
|
password => $args{password}, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
11
|
|
|
|
|
140
|
return bless { %args }, $class; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
4
|
|
|
4
|
1
|
23
|
sub connection_info { return @{ $_[0] }{qw( dsn username password )} } |
|
4
|
|
|
|
|
84
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub dbh { |
46
|
4
|
|
|
4
|
1
|
5520
|
my ( $self, $attr ) = @_; |
47
|
4
|
|
66
|
|
|
101
|
return $self->{dbh} ||= DBI->connect( $self->connection_info(), $attr ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
'IDENTITY'; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |