Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Relationship/BelongsTo.pm |
Statements | Executed 478 statements in 1.81ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
29 | 29 | 20 | 1.23ms | 6.04ms | belongs_to | DBIx::Class::Relationship::BelongsTo::
58 | 2 | 1 | 119µs | 119µs | CORE:match (opcode) | DBIx::Class::Relationship::BelongsTo::
1 | 1 | 1 | 15µs | 17µs | BEGIN@7 | DBIx::Class::Relationship::BelongsTo::
1 | 1 | 1 | 8µs | 137µs | BEGIN@10 | DBIx::Class::Relationship::BelongsTo::
1 | 1 | 1 | 7µs | 19µs | BEGIN@8 | DBIx::Class::Relationship::BelongsTo::
1 | 1 | 1 | 7µs | 41µs | BEGIN@9 | DBIx::Class::Relationship::BelongsTo::
0 | 0 | 0 | 0s | 0s | __ANON__[:29] | DBIx::Class::Relationship::BelongsTo::
0 | 0 | 0 | 0s | 0s | __ANON__[:32] | DBIx::Class::Relationship::BelongsTo::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package # hide from PAUSE | ||||
2 | DBIx::Class::Relationship::BelongsTo; | ||||
3 | |||||
4 | # Documentation for these methods can be found in | ||||
5 | # DBIx::Class::Relationship | ||||
6 | |||||
7 | 3 | 20µs | 2 | 19µs | # spent 17µs (15+2) within DBIx::Class::Relationship::BelongsTo::BEGIN@7 which was called:
# once (15µs+2µs) by Class::C3::Componentised::ensure_class_loaded at line 7 # spent 17µs making 1 call to DBIx::Class::Relationship::BelongsTo::BEGIN@7
# spent 2µs making 1 call to strict::import |
8 | 3 | 18µs | 2 | 30µs | # spent 19µs (7+11) within DBIx::Class::Relationship::BelongsTo::BEGIN@8 which was called:
# once (7µs+11µs) by Class::C3::Componentised::ensure_class_loaded at line 8 # spent 19µs making 1 call to DBIx::Class::Relationship::BelongsTo::BEGIN@8
# spent 11µs making 1 call to warnings::import |
9 | 3 | 19µs | 2 | 75µs | # spent 41µs (7+34) within DBIx::Class::Relationship::BelongsTo::BEGIN@9 which was called:
# once (7µs+34µs) by Class::C3::Componentised::ensure_class_loaded at line 9 # spent 41µs making 1 call to DBIx::Class::Relationship::BelongsTo::BEGIN@9
# spent 34µs making 1 call to Exporter::import |
10 | 3 | 378µs | 2 | 266µs | # spent 137µs (8+129) within DBIx::Class::Relationship::BelongsTo::BEGIN@10 which was called:
# once (8µs+129µs) by Class::C3::Componentised::ensure_class_loaded at line 10 # spent 137µs making 1 call to DBIx::Class::Relationship::BelongsTo::BEGIN@10
# spent 129µs making 1 call to namespace::clean::import |
11 | |||||
12 | 1 | 2µs | our %_pod_inherit_config = | ||
13 | ( | ||||
14 | class_map => { 'DBIx::Class::Relationship::BelongsTo' => 'DBIx::Class::Relationship' } | ||||
15 | ); | ||||
16 | |||||
17 | # spent 6.04ms (1.23+4.81) within DBIx::Class::Relationship::BelongsTo::belongs_to which was called 29 times, avg 208µs/call:
# once (58µs+323µs) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@1 at line 36 of Tapper/Schema/TestrunDB/Result/TestrunScheduling.pm
# once (59µs+200µs) by Class::C3::Componentised::ensure_class_loaded at line 26 of Tapper/Schema/ReportsDB/Result/ReportTopic.pm
# once (49µs+205µs) by Class::C3::Componentised::ensure_class_loaded at line 36 of Tapper/Schema/ReportsDB/Result/Tap.pm
# once (53µs+195µs) by Class::C3::Componentised::ensure_class_loaded at line 35 of Tapper/Schema/ReportsDB/Result/ReportFile.pm
# once (59µs+188µs) by Class::C3::Componentised::ensure_class_loaded at line 26 of Tapper/Schema/ReportsDB/Result/ReportgroupArbitrary.pm
# once (61µs+186µs) by Class::C3::Componentised::ensure_class_loaded at line 29 of Tapper/Schema/TestrunDB/Result/ScenarioElement.pm
# once (51µs+194µs) by Class::C3::Componentised::ensure_class_loaded at line 59 of Tapper/Schema/ReportsDB/Result/Report.pm
# once (58µs+186µs) by Class::C3::Componentised::ensure_class_loaded at line 27 of Tapper/Schema/TestrunDB/Result/TestrunRequestedHost.pm
# once (58µs+183µs) by Class::C3::Componentised::ensure_class_loaded at line 25 of Tapper/Schema/TestrunDB/Result/TestrunPrecondition.pm
# once (57µs+182µs) by Class::C3::Componentised::ensure_class_loaded at line 25 of Tapper/Schema/TestrunDB/Result/PrePrecondition.pm
# once (56µs+179µs) by Class::C3::Componentised::ensure_class_loaded at line 25 of Tapper/Schema/TestrunDB/Result/TestrunRequestedFeature.pm
# once (57µs+178µs) by Class::C3::Componentised::ensure_class_loaded at line 27 of Tapper/Schema/TestrunDB/Result/QueueHost.pm
# once (50µs+184µs) by Class::C3::Componentised::ensure_class_loaded at line 31 of Tapper/Schema/ReportsDB/Result/Notification.pm
# once (50µs+181µs) by Class::C3::Componentised::ensure_class_loaded at line 29 of Tapper/Schema/ReportsDB/Result/ReportComment.pm
# once (48µs+183µs) by Class::C3::Componentised::ensure_class_loaded at line 30 of Tapper/Schema/ReportsDB/Result/Contact.pm
# once (48µs+181µs) by Class::C3::Componentised::ensure_class_loaded at line 40 of Tapper/Schema/TestrunDB/Result/Testrun.pm
# once (49µs+176µs) by Class::C3::Componentised::ensure_class_loaded at line 34 of Tapper/Schema/TestrunDB/Result/State.pm
# once (48µs+176µs) by Class::C3::Componentised::ensure_class_loaded at line 33 of Tapper/Schema/TestrunDB/Result/HostFeature.pm
# once (48µs+176µs) by Class::C3::Componentised::ensure_class_loaded at line 33 of Tapper/Schema/TestrunDB/Result/Message.pm
# once (19µs+142µs) by Class::C3::Componentised::ensure_class_loaded at line 30 of Tapper/Schema/ReportsDB/Result/ReportComment.pm
# once (31µs+109µs) by Class::C3::Componentised::ensure_class_loaded at line 28 of Tapper/Schema/ReportsDB/Result/ReportgroupTestrun.pm
# once (23µs+114µs) by Class::C3::Componentised::ensure_class_loaded at line 26 of Tapper/Schema/TestrunDB/Result/TestrunPrecondition.pm
# once (20µs+117µs) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@1 at line 37 of Tapper/Schema/TestrunDB/Result/TestrunScheduling.pm
# once (19µs+117µs) by Class::C3::Componentised::ensure_class_loaded at line 30 of Tapper/Schema/TestrunDB/Result/ScenarioElement.pm
# once (19µs+113µs) by Class::C3::Componentised::ensure_class_loaded at line 28 of Tapper/Schema/TestrunDB/Result/QueueHost.pm
# once (20µs+112µs) by Class::C3::Componentised::ensure_class_loaded at line 28 of Tapper/Schema/TestrunDB/Result/TestrunRequestedHost.pm
# once (22µs+109µs) by Class::C3::Componentised::ensure_class_loaded at line 26 of Tapper/Schema/TestrunDB/Result/PrePrecondition.pm
# once (20µs+108µs) by Class::C3::Componentised::ensure_class_loaded at line 41 of Tapper/Schema/TestrunDB/Result/Testrun.pm
# once (19µs+106µs) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@1 at line 38 of Tapper/Schema/TestrunDB/Result/TestrunScheduling.pm | ||||
18 | 29 | 40µs | my ($class, $rel, $f_class, $cond, $attrs) = @_; | ||
19 | |||||
20 | # assume a foreign key contraint unless defined otherwise | ||||
21 | 29 | 43µs | $attrs->{is_foreign_key_constraint} = 1 | ||
22 | if not exists $attrs->{is_foreign_key_constraint}; | ||||
23 | 29 | 28µs | $attrs->{undef_on_null_fk} = 1 | ||
24 | if not exists $attrs->{undef_on_null_fk}; | ||||
25 | |||||
26 | # no join condition or just a column name | ||||
27 | 29 | 41µs | if (!ref $cond) { | ||
28 | $class->ensure_class_loaded($f_class); | ||||
29 | my %f_primaries = map { $_ => 1 } try { $f_class->_pri_cols } | ||||
30 | catch { | ||||
31 | $class->throw_exception( "Can't infer join condition for ${rel} on ${class}: $_"); | ||||
32 | }; | ||||
33 | |||||
34 | my ($pri, $too_many) = keys %f_primaries; | ||||
35 | $class->throw_exception( | ||||
36 | "Can't infer join condition for ${rel} on ${class}; ". | ||||
37 | "${f_class} has multiple primary keys" | ||||
38 | ) if $too_many; | ||||
39 | |||||
40 | my $fk = defined $cond ? $cond : $rel; | ||||
41 | $class->throw_exception( | ||||
42 | "Can't infer join condition for ${rel} on ${class}; ". | ||||
43 | "$fk is not a column of $class" | ||||
44 | ) unless $class->has_column($fk); | ||||
45 | |||||
46 | $cond = { "foreign.${pri}" => "self.${fk}" }; | ||||
47 | |||||
48 | } | ||||
49 | # explicit join condition | ||||
50 | elsif (ref $cond) { | ||||
51 | 29 | 31µs | if (ref $cond eq 'HASH') { # ARRAY is also valid | ||
52 | 29 | 6µs | my $cond_rel; | ||
53 | 29 | 31µs | for (keys %$cond) { | ||
54 | 29 | 112µs | 29 | 33µs | if (m/\./) { # Explicit join condition # spent 33µs making 29 calls to DBIx::Class::Relationship::BelongsTo::CORE:match, avg 1µs/call |
55 | 29 | 7µs | $cond_rel = $cond; | ||
56 | 29 | 33µs | last; | ||
57 | } | ||||
58 | $cond_rel->{"foreign.$_"} = "self.".$cond->{$_}; | ||||
59 | } | ||||
60 | 29 | 11µs | $cond = $cond_rel; | ||
61 | } | ||||
62 | } | ||||
63 | # dunno | ||||
64 | else { | ||||
65 | $class->throw_exception( | ||||
66 | 'third argument for belongs_to must be undef, a column name, '. | ||||
67 | 'or a join condition' | ||||
68 | ); | ||||
69 | } | ||||
70 | |||||
71 | 29 | 185µs | 29 | 511µs | my $acc_type = ( # spent 511µs making 29 calls to DBIx::Class::ResultSourceProxy::has_column, avg 18µs/call |
72 | ref $cond eq 'HASH' | ||||
73 | and | ||||
74 | keys %$cond == 1 | ||||
75 | and | ||||
76 | $class->has_column($rel) | ||||
77 | ) ? 'filter' : 'single'; | ||||
78 | |||||
79 | 29 | 209µs | 29 | 86µs | my $fk_columns = ($acc_type eq 'single' and ref $cond eq 'HASH') # spent 86µs making 29 calls to DBIx::Class::Relationship::BelongsTo::CORE:match, avg 3µs/call |
80 | 29 | 83µs | ? { map { $_ =~ /^self\.(.+)/ ? ( $1 => 1 ) : () } (values %$cond ) } | ||
81 | : undef | ||||
82 | ; | ||||
83 | |||||
84 | $class->add_relationship($rel, $f_class, | ||||
85 | $cond, | ||||
86 | { | ||||
87 | accessor => $acc_type, | ||||
88 | $fk_columns ? ( fk_columns => $fk_columns ) : (), | ||||
89 | 29 | 372µs | 29 | 4.18ms | %{$attrs || {}} # spent 4.18ms making 29 calls to DBIx::Class::ResultSourceProxy::add_relationship, avg 144µs/call |
90 | } | ||||
91 | ); | ||||
92 | |||||
93 | 29 | 135µs | return 1; | ||
94 | } | ||||
95 | |||||
96 | # Attempt to remove the POD so it (maybe) falls off the indexer | ||||
97 | |||||
98 | #=head1 AUTHORS | ||||
99 | # | ||||
100 | #Alexander Hartmaier <Alexander.Hartmaier@t-systems.at> | ||||
101 | # | ||||
102 | #Matt S. Trout <mst@shadowcatsystems.co.uk> | ||||
103 | # | ||||
104 | #=cut | ||||
105 | |||||
106 | 1 | 8µs | 1 | 186µs | 1; # spent 186µs making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26] |
# spent 119µs within DBIx::Class::Relationship::BelongsTo::CORE:match which was called 58 times, avg 2µs/call:
# 29 times (86µs+0s) by DBIx::Class::Relationship::BelongsTo::belongs_to at line 79, avg 3µs/call
# 29 times (33µs+0s) by DBIx::Class::Relationship::BelongsTo::belongs_to at line 54, avg 1µs/call |