Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Relationship/HasOne.pm |
Statements | Executed 136 statements in 836µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
7 | 1 | 1 | 121µs | 389µs | _validate_has_one_condition | DBIx::Class::Relationship::HasOne::
7 | 1 | 1 | 113µs | 1.24ms | _has_one | DBIx::Class::Relationship::HasOne::
7 | 7 | 3 | 40µs | 1.28ms | might_have | DBIx::Class::Relationship::HasOne::
7 | 1 | 1 | 14µs | 14µs | CORE:match (opcode) | DBIx::Class::Relationship::HasOne::
1 | 1 | 1 | 13µs | 15µs | BEGIN@4 | DBIx::Class::Relationship::HasOne::
1 | 1 | 1 | 8µs | 17µs | BEGIN@5 | DBIx::Class::Relationship::HasOne::
1 | 1 | 1 | 8µs | 98µs | BEGIN@6 | DBIx::Class::Relationship::HasOne::
1 | 1 | 1 | 7µs | 160µs | BEGIN@8 | DBIx::Class::Relationship::HasOne::
1 | 1 | 1 | 7µs | 46µs | BEGIN@7 | DBIx::Class::Relationship::HasOne::
0 | 0 | 0 | 0s | 0s | __ANON__[:35] | DBIx::Class::Relationship::HasOne::
0 | 0 | 0 | 0s | 0s | __ANON__[:69] | DBIx::Class::Relationship::HasOne::
0 | 0 | 0 | 0s | 0s | __ANON__[:72] | DBIx::Class::Relationship::HasOne::
0 | 0 | 0 | 0s | 0s | _get_primary_key | DBIx::Class::Relationship::HasOne::
0 | 0 | 0 | 0s | 0s | has_one | DBIx::Class::Relationship::HasOne::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package # hide from PAUSE | ||||
2 | DBIx::Class::Relationship::HasOne; | ||||
3 | |||||
4 | 3 | 19µs | 2 | 18µs | # spent 15µs (13+3) within DBIx::Class::Relationship::HasOne::BEGIN@4 which was called:
# once (13µs+3µs) by Class::C3::Componentised::ensure_class_loaded at line 4 # spent 15µs making 1 call to DBIx::Class::Relationship::HasOne::BEGIN@4
# spent 2µs making 1 call to strict::import |
5 | 3 | 17µs | 2 | 27µs | # spent 17µs (8+10) within DBIx::Class::Relationship::HasOne::BEGIN@5 which was called:
# once (8µs+10µs) by Class::C3::Componentised::ensure_class_loaded at line 5 # spent 17µs making 1 call to DBIx::Class::Relationship::HasOne::BEGIN@5
# spent 10µs making 1 call to warnings::import |
6 | 3 | 20µs | 2 | 189µs | # spent 98µs (8+91) within DBIx::Class::Relationship::HasOne::BEGIN@6 which was called:
# once (8µs+91µs) by Class::C3::Componentised::ensure_class_loaded at line 6 # spent 98µs making 1 call to DBIx::Class::Relationship::HasOne::BEGIN@6
# spent 91µs making 1 call to DBIx::Class::Carp::import |
7 | 3 | 18µs | 2 | 86µs | # spent 46µs (7+40) within DBIx::Class::Relationship::HasOne::BEGIN@7 which was called:
# once (7µs+40µs) by Class::C3::Componentised::ensure_class_loaded at line 7 # spent 46µs making 1 call to DBIx::Class::Relationship::HasOne::BEGIN@7
# spent 40µs making 1 call to Exporter::import |
8 | 3 | 468µs | 2 | 313µs | # spent 160µs (7+153) within DBIx::Class::Relationship::HasOne::BEGIN@8 which was called:
# once (7µs+153µs) by Class::C3::Componentised::ensure_class_loaded at line 8 # spent 160µs making 1 call to DBIx::Class::Relationship::HasOne::BEGIN@8
# spent 153µs making 1 call to namespace::clean::import |
9 | |||||
10 | 1 | 2µs | our %_pod_inherit_config = | ||
11 | ( | ||||
12 | class_map => { 'DBIx::Class::Relationship::HasOne' => 'DBIx::Class::Relationship' } | ||||
13 | ); | ||||
14 | |||||
15 | # spent 1.28ms (40µs+1.24) within DBIx::Class::Relationship::HasOne::might_have which was called 7 times, avg 183µs/call:
# once (9µs+289µs) by Class::C3::Componentised::ensure_class_loaded at line 27 of Tapper/Schema/ReportsDB/Result/ReportgroupTestrun.pm
# once (10µs+172µs) by Class::C3::Componentised::ensure_class_loaded at line 46 of Tapper/Schema/TestrunDB/Result/Testrun.pm
# once (11µs+170µs) by Class::C3::Componentised::ensure_class_loaded at line 60 of Tapper/Schema/ReportsDB/Result/Report.pm
# once (2µs+173µs) by Class::C3::Componentised::ensure_class_loaded at line 48 of Tapper/Schema/TestrunDB/Result/Testrun.pm
# once (3µs+147µs) by Class::C3::Componentised::ensure_class_loaded at line 47 of Tapper/Schema/TestrunDB/Result/Testrun.pm
# once (3µs+147µs) by Class::C3::Componentised::ensure_class_loaded at line 61 of Tapper/Schema/ReportsDB/Result/Report.pm
# once (2µs+146µs) by Class::C3::Componentised::ensure_class_loaded at line 62 of Tapper/Schema/ReportsDB/Result/Report.pm | ||||
16 | 7 | 47µs | 7 | 1.24ms | shift->_has_one('LEFT' => @_); # spent 1.24ms making 7 calls to DBIx::Class::Relationship::HasOne::_has_one, avg 178µs/call |
17 | } | ||||
18 | |||||
19 | sub has_one { | ||||
20 | shift->_has_one(undef() => @_); | ||||
21 | } | ||||
22 | |||||
23 | # spent 1.24ms (113µs+1.13) within DBIx::Class::Relationship::HasOne::_has_one which was called 7 times, avg 178µs/call:
# 7 times (113µs+1.13ms) by DBIx::Class::Relationship::HasOne::might_have at line 16, avg 178µs/call | ||||
24 | 42 | 105µs | my ($class, $join_type, $rel, $f_class, $cond, $attrs) = @_; | ||
25 | unless (ref $cond) { | ||||
26 | $class->ensure_class_loaded($f_class); | ||||
27 | |||||
28 | my $pri = $class->_get_primary_key; | ||||
29 | |||||
30 | $class->throw_exception( | ||||
31 | "might_have/has_one needs a primary key to infer a join; ". | ||||
32 | "${class} has none" | ||||
33 | ) if !defined $pri && (!defined $cond || !length $cond); | ||||
34 | |||||
35 | my $f_class_loaded = try { $f_class->columns }; | ||||
36 | my ($f_key,$too_many,$guess); | ||||
37 | if (defined $cond && length $cond) { | ||||
38 | $f_key = $cond; | ||||
39 | $guess = "caller specified foreign key '$f_key'"; | ||||
40 | } elsif ($f_class_loaded && $f_class->has_column($rel)) { | ||||
41 | $f_key = $rel; | ||||
42 | $guess = "using given relationship '$rel' for foreign key"; | ||||
43 | } else { | ||||
44 | $f_key = $class->_get_primary_key($f_class); | ||||
45 | $guess = "using primary key of foreign class for foreign key"; | ||||
46 | } | ||||
47 | $class->throw_exception( | ||||
48 | "No such column ${f_key} on foreign class ${f_class} ($guess)" | ||||
49 | ) if $f_class_loaded && !$f_class->has_column($f_key); | ||||
50 | $cond = { "foreign.${f_key}" => "self.${pri}" }; | ||||
51 | } | ||||
52 | 7 | 389µs | $class->_validate_has_one_condition($cond); # spent 389µs making 7 calls to DBIx::Class::Relationship::HasOne::_validate_has_one_condition, avg 56µs/call | ||
53 | |||||
54 | my $default_cascade = ref $cond eq 'CODE' ? 0 : 1; | ||||
55 | |||||
56 | $class->add_relationship($rel, $f_class, | ||||
57 | $cond, | ||||
58 | { accessor => 'single', | ||||
59 | cascade_update => $default_cascade, | ||||
60 | cascade_delete => $default_cascade, | ||||
61 | ($join_type ? ('join_type' => $join_type) : ()), | ||||
62 | 7 | 742µs | %{$attrs || {}} }); # spent 742µs making 7 calls to DBIx::Class::ResultSourceProxy::add_relationship, avg 106µs/call | ||
63 | 1; | ||||
64 | } | ||||
65 | |||||
66 | sub _get_primary_key { | ||||
67 | my ( $class, $target_class ) = @_; | ||||
68 | $target_class ||= $class; | ||||
69 | my ($pri, $too_many) = try { $target_class->_pri_cols } | ||||
70 | catch { | ||||
71 | $class->throw_exception("Can't infer join condition on ${target_class}: $_"); | ||||
72 | }; | ||||
73 | |||||
74 | $class->throw_exception( | ||||
75 | "might_have/has_one can only infer join for a single primary key; ". | ||||
76 | "${class} has more" | ||||
77 | ) if $too_many; | ||||
78 | return $pri; | ||||
79 | } | ||||
80 | |||||
81 | # spent 389µs (121+268) within DBIx::Class::Relationship::HasOne::_validate_has_one_condition which was called 7 times, avg 56µs/call:
# 7 times (121µs+268µs) by DBIx::Class::Relationship::HasOne::_has_one at line 52, avg 56µs/call | ||||
82 | 28 | 35µs | my ($class, $cond ) = @_; | ||
83 | |||||
84 | return if $ENV{DBIC_DONT_VALIDATE_RELS}; | ||||
85 | return unless 'HASH' eq ref $cond; | ||||
86 | foreach my $foreign_id ( keys %$cond ) { | ||||
87 | 42 | 94µs | my $self_id = $cond->{$foreign_id}; | ||
88 | |||||
89 | # we can ignore a bad $self_id because add_relationship handles this | ||||
90 | # warning | ||||
91 | 7 | 14µs | return unless $self_id =~ /^self\.(.*)$/; # spent 14µs making 7 calls to DBIx::Class::Relationship::HasOne::CORE:match, avg 2µs/call | ||
92 | my $key = $1; | ||||
93 | 7 | 120µs | $class->throw_exception("Defining rel on ${class} that includes ${key} but no such column defined here yet") # spent 120µs making 7 calls to DBIx::Class::ResultSourceProxy::has_column, avg 17µs/call | ||
94 | unless $class->has_column($key); | ||||
95 | 7 | 134µs | my $column_info = $class->column_info($key); # spent 134µs making 7 calls to DBIx::Class::ResultSourceProxy::column_info, avg 19µs/call | ||
96 | if ( $column_info->{is_nullable} ) { | ||||
97 | carp(qq'"might_have/has_one" must not be on columns with is_nullable set to true ($class/$key). This might indicate an incorrect use of those relationship helpers instead of belongs_to.'); | ||||
98 | } | ||||
99 | } | ||||
100 | } | ||||
101 | |||||
102 | 1 | 11µs | 1 | 410µs | 1; # spent 410µs making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26] |
# spent 14µs within DBIx::Class::Relationship::HasOne::CORE:match which was called 7 times, avg 2µs/call:
# 7 times (14µs+0s) by DBIx::Class::Relationship::HasOne::_validate_has_one_condition at line 91, avg 2µs/call |