blib/lib/DBIO/Test/Schema/Artist.pm

filter: Statementstmt 78.4% 40 / 51 Branchbran 16.6% 1 / 6 Conditioncond 42.8% 6 / 14 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 54.5% 6 / 11 Podpod 50.0% 1 / 2 totaltotal 59.3% 54 / 91 CC 10 SCAR 15.9
CC
10
Cov
66%
sqlt_deploy_hook
12.0
__ANON__
6.0
__ANON__
6.0
CRAP 4.9
« blib/lib/DBIO/Deploy/Base/TempDatabase.pm ↑ Summary blib/lib/DBIO/Storage/DBI/UniqueIdentifier.pm »
1 package DBIO::Test::Schema::Artist;
2 # ABSTRACT: Test result class for the artist table
3  
4 256 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 256 our $VERSION = '0.900007';
7  
8 256 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 256 ▶use base 'DBIO::Test::BaseResult';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 256 ▶use DBIO::Test::Util 'check_customcond_args';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 256 __PACKAGE__->table('artist');
14 256 __PACKAGE__->source_info({
15 "source_info_key_A" => "source_info_value_A",
16 "source_info_key_B" => "source_info_value_B",
17 "source_info_key_C" => "source_info_value_C",
18 });
19 256 __PACKAGE__->add_columns(
20 'artistid' => {
21 data_type => 'integer',
22 is_auto_increment => 1,
23 },
24 'name' => {
25 data_type => 'varchar',
26 size => 100,
27 is_nullable => 1,
28 },
29 rank => {
30 data_type => 'integer',
31 default_value => 13,
32 },
33 charfield => {
34 data_type => 'char',
35 size => 10,
36 is_nullable => 1,
37 },
38 );
39 256 __PACKAGE__->set_primary_key('artistid');
40 256 __PACKAGE__->add_unique_constraint(['name']);
41 256 __PACKAGE__->add_unique_constraint(artist_artistid => ['artistid']); # do not remove, part of a test
42 256 __PACKAGE__->add_unique_constraint(u_nullable => [qw/charfield rank/]);
43  
44  
45 256 __PACKAGE__->mk_classdata('field_name_for', {
46 artistid => 'primary key',
47 name => 'artist name',
48 });
49  
50 # the undef condition in this rel is *deliberate*
51 # tests oddball legacy syntax
52 256 __PACKAGE__->has_many(
53 cds => 'DBIO::Test::Schema::CD', undef,
54 { order_by => { -asc => 'year'} },
55 );
56  
57 __PACKAGE__->has_many(
58 cds_cref_cond => 'DBIO::Test::Schema::CD',
59 1 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
60 # This is for test purposes only. A regular user does not
61 # need to sanity check the passed-in arguments, this is what
62 # the tests are for :)
63 1 my $args = &check_customcond_args;
64  
65 return (
66 { "$args->{foreign_alias}.artist" => { '=' => { -ident => "$args->{self_alias}.artistid"} },
67 },
68 $args->{self_result_object} && {
69 "$args->{foreign_alias}.artist" => $args->{self_rowobj}->artistid, # keep old rowobj syntax as a test
70 }
71 1 ▶ );
Condition50%1/2
$args->{'self_result_object'} && {"$args->{'foreign_alias'}.artist", $args->{'self_rowobj'}->artistid}
!ll
10
MC/DC0%0/1
$args->{'self_result_object'} && {"$args->{'foreign_alias'}.artist", $args->{'self_rowobj'}->artistid}
$args->{'self_result_object'}
Truth table50%1/2
A
A= $args->{'self_result_object'}
Aresult
00
11
72 },
73 256 );
74  
75 __PACKAGE__->has_many(
76 cds_80s => 'DBIO::Test::Schema::CD',
77 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
78 # This is for test purposes only. A regular user does not
79 # need to sanity check the passed-in arguments, this is what
80 # the tests are for :)
81 0 my $args = &check_customcond_args;
82  
83 return (
84 { "$args->{foreign_alias}.artist" => { '=' => \ "$args->{self_alias}.artistid" },
85 "$args->{foreign_alias}.year" => { '>' => 1979, '<' => 1990 },
86 },
87 $args->{self_result_object} && {
88 0 ▶ "$args->{foreign_alias}.artist" => { '=' => \[ '?', $args->{self_result_object}->artistid ] },
Condition0%0/2
$args->{'self_result_object'} && {"$args->{'foreign_alias'}.artist", {'=', \['?', $args->{'self_result_object'}->artistid]}, "$args->{'foreign_alias'}.year", {'>', 1979, '<', 1990}}
!ll
00
MC/DC0%0/1
$args->{'self_result_object'} && {"$args->{'foreign_alias'}.artist", {'=', \['?', $args->{'self_result_object'}->artistid]}, "$args->{'foreign_alias'}.year", {'>', 1979, '<', 1990}}
$args->{'self_result_object'}
Truth table0%0/2
A
A= $args->{'self_result_object'}
Aresult
00
11
89 "$args->{foreign_alias}.year" => { '>' => 1979, '<' => 1990 },
90 }
91 );
92 },
93 256 );
94  
95  
96 __PACKAGE__->has_many(
97 cds_84 => 'DBIO::Test::Schema::CD',
98 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
99 # This is for test purposes only. A regular user does not
100 # need to sanity check the passed-in arguments, this is what
101 # the tests are for :)
102 0 my $args = &check_customcond_args;
103  
104 return (
105 { "$args->{foreign_alias}.artist" => { -ident => "$args->{self_alias}.artistid" },
106 "$args->{foreign_alias}.year" => 1984,
107 },
108 $args->{self_result_object} && {
109 "$args->{foreign_alias}.artist" => $args->{self_result_object}->artistid,
110 0 ▶ "$args->{foreign_alias}.year" => 1984,
Condition0%0/2
$args->{'self_result_object'} && {"$args->{'foreign_alias'}.artist", $args->{'self_result_object'}->artistid, "$args->{'foreign_alias'}.year", 1984}
!ll
00
MC/DC0%0/1
$args->{'self_result_object'} && {"$args->{'foreign_alias'}.artist", $args->{'self_result_object'}->artistid, "$args->{'foreign_alias'}.year", 1984}
$args->{'self_result_object'}
Truth table0%0/2
A
A= $args->{'self_result_object'}
Aresult
00
11
111 }
112 );
113 }
114 256 );
115  
116  
117 __PACKAGE__->has_many(
118 cds_90s => 'DBIO::Test::Schema::CD',
119 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
120 # This is for test purposes only. A regular user does not
121 # need to sanity check the passed-in arguments, this is what
122 # the tests are for :)
123 0 my $args = &check_customcond_args;
124  
125 return (
126 0 { "$args->{foreign_alias}.artist" => { -ident => "$args->{self_alias}.artistid" },
127 "$args->{foreign_alias}.year" => { '>' => 1989, '<' => 2000 },
128 }
129 );
130 }
131 256 );
132  
133  
134 256 __PACKAGE__->has_many(
135 cds_unordered => 'DBIO::Test::Schema::CD'
136 );
137 256 __PACKAGE__->has_many(
138 cds_very_very_very_long_relationship_name => 'DBIO::Test::Schema::CD'
139 );
140  
141 256 __PACKAGE__->has_many( twokeys => 'DBIO::Test::Schema::TwoKeys' );
142 256 __PACKAGE__->has_many( onekeys => 'DBIO::Test::Schema::OneKey' );
143  
144 256 __PACKAGE__->has_many(
145 artist_undirected_maps => 'DBIO::Test::Schema::ArtistUndirectedMap',
146 [ {'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'} ],
147 { cascade_copy => 0 } # this would *so* not make sense
148 );
149  
150 256 __PACKAGE__->has_many(
151 artwork_to_artist => 'DBIO::Test::Schema::Artwork_to_Artist' => 'artist_id'
152 );
153 256 __PACKAGE__->many_to_many('artworks', 'artwork_to_artist', 'artwork');
154  
155 __PACKAGE__->has_many(
156 cds_without_genre => 'DBIO::Test::Schema::CD',
157 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
158 # This is for test purposes only. A regular user does not
159 # need to sanity check the passed-in arguments, this is what
160 # the tests are for :)
161 0 my $args = &check_customcond_args;
162  
163 return (
164 {
165 "$args->{foreign_alias}.artist" => { -ident => "$args->{self_alias}.artistid" },
166 "$args->{foreign_alias}.genreid" => undef,
167 }, $args->{self_result_object} && {
168 "$args->{foreign_alias}.artist" => $args->{self_result_object}->artistid,
169 0 ▶ "$args->{foreign_alias}.genreid" => undef,
Condition0%0/2
$args->{'self_result_object'} && {"$args->{'foreign_alias'}.artist", $args->{'self_result_object'}->artistid, "$args->{'foreign_alias'}.genreid", undef}
!ll
00
MC/DC0%0/1
$args->{'self_result_object'} && {"$args->{'foreign_alias'}.artist", $args->{'self_result_object'}->artistid, "$args->{'foreign_alias'}.genreid", undef}
$args->{'self_result_object'}
Truth table0%0/2
A
A= $args->{'self_result_object'}
Aresult
00
11
170 }
171 ),
172 },
173 256 );
174  
175 0 ▶sub sqlt_deploy_hook {
Subroutine sqlt_deploy_hook: not called CC=3 SCAR=24.8
Pod undocumented
176 0 my ($self, $sqlt_table) = @_;
177  
178 0 ▶ if ($sqlt_table->schema->translator->producer_type =~ /SQLite$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sqlt_table->schema->translator->producer_type =~ /SQLite$/) 0 0 0
179 0 ▶ $sqlt_table->add_index( name => 'artist_name_hookidx', fields => ['name'] )
Branch: 1 branch
BranchTrueFalseTotal
$sqlt_table->add_index("name", "artist_name_hookidx", "fields", ["name"]) or die $sqlt_table->error 0 0 0
180 or die $sqlt_table->error;
181 }
182 }
183  
184 2252 ▶sub store_column {
Subroutine store_column: called CC=4 SCAR=14.1
Pod documented
185 2252 my ($self, $name, $value) = @_;
186 2252 ▶ $value = 'X '.$value if ($name eq 'name' && $value && $value =~ /(X )?store_column test/);
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "name" and $value and $value =~ /(X )?store_column test/ 0 2252 2252
Condition83%5/6
$name eq "name" and $value and $value =~ /(X )?store_column test/
!ll&&!rl&&r
14268260
$name eq "name" and $value
!ll&&!rl&&r
14251826
MC/DC0%0/3
$name eq "name" and $value and $value =~ /(X )?store_column test/
$name eq "name" $value $value =~ /(X )?store_column test/
Truth table75%3/4
A and B and C
A= $name eq "name"B= $valueC= $value =~ /(X )?store_column test/
ABCresult
0XX0
10X0
1100
1111
187 2252 $self->next::method($name, $value);
188 }
189  
190  
191 256 1;
192  
193 __END__
« blib/lib/DBIO/Deploy/Base/TempDatabase.pm ↑ Summary blib/lib/DBIO/Storage/DBI/UniqueIdentifier.pm »