line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Chado::Schema::Test; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
5
|
|
|
5
|
|
262587
|
$Bio::Chado::Schema::Test::AUTHORITY = 'cpan:RBUELS'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
5
|
|
|
5
|
|
77
|
$Bio::Chado::Schema::Test::VERSION = '0.08001'; # TRIAL |
7
|
|
|
|
|
|
|
} |
8
|
5
|
|
|
5
|
|
35
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
80
|
|
9
|
5
|
|
|
5
|
|
20
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
196
|
|
10
|
5
|
|
|
5
|
|
1712
|
use Carp::Clan qr/^Bio::Chado::Schema/; |
|
5
|
|
|
|
|
14309
|
|
|
5
|
|
|
|
|
37
|
|
11
|
5
|
|
|
5
|
|
2137
|
use Bio::Chado::Schema; |
|
5
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
2443
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub has_custom_dsn { |
16
|
5
|
50
|
|
5
|
1
|
28175
|
return $ENV{"BCS_TEST_DSN"} ? 1 : 0; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _sqlite_dbfilename { |
20
|
10
|
|
|
10
|
|
217
|
return "t/var/BCS.db"; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _sqlite_dbname { |
24
|
5
|
|
|
5
|
|
13
|
my $self = shift; |
25
|
5
|
|
|
|
|
15
|
my %args = @_; |
26
|
5
|
|
|
|
|
27
|
return $self->_sqlite_dbfilename; # if $args{sqlite_use_file} or $ENV{"BCS_SQLITE_USE_FILE"}; |
27
|
0
|
|
|
|
|
0
|
return ":memory:"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _database { |
31
|
5
|
|
|
5
|
|
16
|
my $self = shift; |
32
|
5
|
|
|
|
|
19
|
my %args = @_; |
33
|
5
|
|
|
|
|
25
|
my $db_file = $self->_sqlite_dbname(%args); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#warn "Removing $db_file"; |
36
|
|
|
|
|
|
|
#unlink($db_file) if -e $db_file; |
37
|
|
|
|
|
|
|
#unlink($db_file . "-journal") if -e $db_file . "-journal"; |
38
|
5
|
100
|
|
|
|
313
|
mkdir("t/var") unless -d "t/var"; |
39
|
|
|
|
|
|
|
|
40
|
5
|
|
33
|
|
|
54
|
my $dsn = $ENV{"BCS_TEST_DSN"} || "dbi:SQLite:${db_file}"; |
41
|
5
|
|
50
|
|
|
39
|
my $dbuser = $ENV{"BCS_TEST_DBUSER"} || ''; |
42
|
5
|
|
50
|
|
|
32
|
my $dbpass = $ENV{"BCS_TEST_DBPASS"} || ''; |
43
|
|
|
|
|
|
|
|
44
|
5
|
|
|
|
|
25
|
my @connect_info = ($dsn, $dbuser, $dbpass, { AutoCommit => 1, %args }); |
45
|
|
|
|
|
|
|
|
46
|
5
|
|
|
|
|
59
|
return @connect_info; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub init_schema { |
50
|
5
|
|
|
5
|
1
|
441
|
my $self = shift; |
51
|
5
|
|
|
|
|
383
|
my %args = @_; |
52
|
5
|
50
|
|
|
|
29
|
my $should_deploy = $ENV{"BCS_TEST_DSN"} ? 0 : 1 ; |
53
|
|
|
|
|
|
|
|
54
|
5
|
|
|
|
|
12
|
my $schema; |
55
|
|
|
|
|
|
|
|
56
|
5
|
50
|
|
|
|
17
|
if ($args{compose_connection}) { |
57
|
0
|
|
|
|
|
0
|
$schema = Bio::Chado::Schema->compose_connection( |
58
|
|
|
|
|
|
|
'Bio::Chado::Schema::Test', $self->_database(%args) |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
} else { |
61
|
5
|
|
|
|
|
70
|
$schema = Bio::Chado::Schema->compose_namespace('Bio::Chado::Schema::Test'); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
5
|
50
|
|
|
|
1173135
|
if ($args{storage_type}) { |
65
|
0
|
|
|
|
|
0
|
$schema->storage_type($args{storage_type}); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
5
|
|
|
|
|
36
|
$schema = $schema->connect($self->_database(%args)); |
69
|
5
|
50
|
|
|
|
1259836
|
$schema->storage->on_connect_do(['PRAGMA synchronous = OFF']) unless $self->has_custom_dsn; |
70
|
|
|
|
|
|
|
|
71
|
5
|
100
|
|
|
|
1237
|
unless ( -e _sqlite_dbfilename() ) { |
72
|
1
|
50
|
|
|
|
13
|
__PACKAGE__->deploy_schema( $schema, $args{deploy_args} ) if $should_deploy; |
73
|
1
|
50
|
|
|
|
8
|
__PACKAGE__->populate_schema( $schema ) if $args{populate}; |
74
|
|
|
|
|
|
|
} |
75
|
5
|
|
|
|
|
35
|
return $schema; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub deploy_schema { |
80
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
81
|
1
|
|
|
|
|
2
|
my $schema = shift; |
82
|
1
|
|
50
|
|
|
8
|
my $args = shift || {}; |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
10
|
$schema->deploy($args); |
85
|
1
|
|
|
|
|
8412122
|
return; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub populate_schema { |
90
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
91
|
0
|
|
|
|
|
|
my $schema = shift; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# $schema->populate('Genre', [ |
94
|
|
|
|
|
|
|
# [qw/genreid name/], |
95
|
|
|
|
|
|
|
# [qw/1 emo/], |
96
|
|
|
|
|
|
|
# ]); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |