| Filename | /usr/share/perl5/DBIx/Class/Relationship/HasOne.pm |
| Statements | Executed 199 statements in 1.68ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 11 | 1 | 1 | 368µs | 829µs | DBIx::Class::Relationship::HasOne::_validate_has_one_condition |
| 11 | 1 | 1 | 210µs | 2.54ms | DBIx::Class::Relationship::HasOne::_has_one |
| 11 | 11 | 6 | 67µs | 2.61ms | DBIx::Class::Relationship::HasOne::might_have |
| 11 | 1 | 1 | 36µs | 36µs | DBIx::Class::Relationship::HasOne::CORE:match (opcode) |
| 1 | 1 | 1 | 16µs | 25µs | DBIx::Class::Relationship::HasOne::BEGIN@4 |
| 1 | 1 | 1 | 10µs | 51µs | DBIx::Class::Relationship::HasOne::BEGIN@6 |
| 1 | 1 | 1 | 8µs | 35µs | DBIx::Class::Relationship::HasOne::BEGIN@7 |
| 1 | 1 | 1 | 8µs | 14µs | DBIx::Class::Relationship::HasOne::BEGIN@5 |
| 1 | 1 | 1 | 7µs | 126µs | DBIx::Class::Relationship::HasOne::BEGIN@8 |
| 0 | 0 | 0 | 0s | 0s | DBIx::Class::Relationship::HasOne::__ANON__[:42] |
| 0 | 0 | 0 | 0s | 0s | DBIx::Class::Relationship::HasOne::__ANON__[:48] |
| 0 | 0 | 0 | 0s | 0s | DBIx::Class::Relationship::HasOne::has_one |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package # hide from PAUSE | ||||
| 2 | DBIx::Class::Relationship::HasOne; | ||||
| 3 | |||||
| 4 | 2 | 38µs | 2 | 33µs | # spent 25µs (16+8) within DBIx::Class::Relationship::HasOne::BEGIN@4 which was called:
# once (16µs+8µs) by Class::C3::Componentised::ensure_class_loaded at line 4 # spent 25µs making 1 call to DBIx::Class::Relationship::HasOne::BEGIN@4
# spent 8µs making 1 call to strict::import |
| 5 | 2 | 31µs | 2 | 21µs | # spent 14µs (8+7) within DBIx::Class::Relationship::HasOne::BEGIN@5 which was called:
# once (8µs+7µs) by Class::C3::Componentised::ensure_class_loaded at line 5 # spent 14µs making 1 call to DBIx::Class::Relationship::HasOne::BEGIN@5
# spent 7µs making 1 call to warnings::import |
| 6 | 2 | 34µs | 2 | 92µs | # spent 51µs (10+41) within DBIx::Class::Relationship::HasOne::BEGIN@6 which was called:
# once (10µs+41µs) by Class::C3::Componentised::ensure_class_loaded at line 6 # spent 51µs making 1 call to DBIx::Class::Relationship::HasOne::BEGIN@6
# spent 41µs making 1 call to DBIx::Class::Carp::import |
| 7 | 2 | 55µs | 2 | 62µs | # spent 35µs (8+27) within DBIx::Class::Relationship::HasOne::BEGIN@7 which was called:
# once (8µs+27µs) by Class::C3::Componentised::ensure_class_loaded at line 7 # spent 35µs making 1 call to DBIx::Class::Relationship::HasOne::BEGIN@7
# spent 27µs making 1 call to Exporter::import |
| 8 | 2 | 844µs | 2 | 244µs | # spent 126µs (7+119) within DBIx::Class::Relationship::HasOne::BEGIN@8 which was called:
# once (7µs+119µs) by Class::C3::Componentised::ensure_class_loaded at line 8 # spent 126µs making 1 call to DBIx::Class::Relationship::HasOne::BEGIN@8
# spent 119µ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 2.61ms (67µs+2.54) within DBIx::Class::Relationship::HasOne::might_have which was called 11 times, avg 237µs/call:
# once (10µs+344µs) by Class::C3::Componentised::ensure_class_loaded at line 367 of Koha/Schema/Result/Aqorder.pm
# once (10µs+299µs) by Class::C3::Componentised::ensure_class_loaded at line 393 of Koha/Schema/Result/Branch.pm
# once (4µs+251µs) by Class::C3::Componentised::ensure_class_loaded at line 382 of Koha/Schema/Result/Aqorder.pm
# once (5µs+243µs) by Class::C3::Componentised::ensure_class_loaded at line 551 of Koha/Schema/Result/Item.pm
# once (7µs+237µs) by Class::C3::Componentised::ensure_class_loaded at line 466 of Koha/Schema/Result/Item.pm
# once (8µs+220µs) by Class::C3::Componentised::ensure_class_loaded at line 160 of Koha/Schema/Result/Itemtype.pm
# once (8µs+219µs) by Class::C3::Componentised::ensure_class_loaded at line 981 of Koha/Schema/Result/Borrower.pm
# once (8µs+217µs) by Class::C3::Componentised::ensure_class_loaded at line 248 of Koha/Schema/Result/Category.pm
# once (2µs+182µs) by Class::C3::Componentised::ensure_class_loaded at line 566 of Koha/Schema/Result/Item.pm
# once (3µs+166µs) by Class::C3::Componentised::ensure_class_loaded at line 626 of Koha/Schema/Result/Item.pm
# once (2µs+161µs) by Class::C3::Componentised::ensure_class_loaded at line 496 of Koha/Schema/Result/Item.pm | ||||
| 16 | 11 | 84µs | 11 | 2.54ms | shift->_has_one('LEFT' => @_); # spent 2.54ms making 11 calls to DBIx::Class::Relationship::HasOne::_has_one, avg 231µs/call |
| 17 | } | ||||
| 18 | |||||
| 19 | sub has_one { | ||||
| 20 | shift->_has_one(undef() => @_); | ||||
| 21 | } | ||||
| 22 | |||||
| 23 | # spent 2.54ms (210µs+2.33) within DBIx::Class::Relationship::HasOne::_has_one which was called 11 times, avg 231µs/call:
# 11 times (210µs+2.33ms) by DBIx::Class::Relationship::HasOne::might_have at line 16, avg 231µs/call | ||||
| 24 | 11 | 10µs | my ($class, $join_type, $rel, $f_class, $cond, $attrs) = @_; | ||
| 25 | 11 | 4µs | unless (ref $cond) { | ||
| 26 | my $pri = $class->result_source_instance->_single_pri_col_or_die; | ||||
| 27 | |||||
| 28 | my ($f_key,$guess,$f_rsrc); | ||||
| 29 | if (defined $cond && length $cond) { | ||||
| 30 | $f_key = $cond; | ||||
| 31 | $guess = "caller specified foreign key '$f_key'"; | ||||
| 32 | } | ||||
| 33 | else { | ||||
| 34 | # at this point we need to load the foreigner, expensive or not | ||||
| 35 | $class->ensure_class_loaded($f_class); | ||||
| 36 | |||||
| 37 | $f_rsrc = try { | ||||
| 38 | my $r = $f_class->result_source_instance; | ||||
| 39 | die "There got to be some columns by now... (exception caught and rewritten by catch below)" | ||||
| 40 | unless $r->columns; | ||||
| 41 | $r; | ||||
| 42 | } | ||||
| 43 | catch { | ||||
| 44 | $class->throw_exception( | ||||
| 45 | "Foreign class '$f_class' does not seem to be a Result class " | ||||
| 46 | . "(or it simply did not load entirely due to a circular relation chain)" | ||||
| 47 | ); | ||||
| 48 | }; | ||||
| 49 | |||||
| 50 | if ($f_rsrc->has_column($rel)) { | ||||
| 51 | $f_key = $rel; | ||||
| 52 | $guess = "using given relationship name '$rel' as foreign key column name"; | ||||
| 53 | } | ||||
| 54 | else { | ||||
| 55 | $f_key = $f_rsrc->_single_pri_col_or_die; | ||||
| 56 | $guess = "using primary key of foreign class for foreign key"; | ||||
| 57 | } | ||||
| 58 | } | ||||
| 59 | |||||
| 60 | # FIXME - this check needs to be moved to schema-composition time... | ||||
| 61 | # # only perform checks if the far side was not preloaded above *AND* | ||||
| 62 | # # appears to have been loaded by something else (has a rsrc_instance) | ||||
| 63 | # if (! $f_rsrc and $f_rsrc = try { $f_class->result_source_instance }) { | ||||
| 64 | # $class->throw_exception( | ||||
| 65 | # "No such column '$f_key' on foreign class ${f_class} ($guess)" | ||||
| 66 | # ) if !$f_rsrc->has_column($f_key); | ||||
| 67 | # } | ||||
| 68 | |||||
| 69 | $cond = { "foreign.${f_key}" => "self.${pri}" }; | ||||
| 70 | } | ||||
| 71 | 11 | 56µs | 11 | 829µs | $class->_validate_has_one_condition($cond); # spent 829µs making 11 calls to DBIx::Class::Relationship::HasOne::_validate_has_one_condition, avg 75µs/call |
| 72 | |||||
| 73 | 11 | 17µs | my $default_cascade = ref $cond eq 'CODE' ? 0 : 1; | ||
| 74 | |||||
| 75 | $class->add_relationship($rel, $f_class, | ||||
| 76 | $cond, | ||||
| 77 | { accessor => 'single', | ||||
| 78 | cascade_update => $default_cascade, | ||||
| 79 | cascade_delete => $default_cascade, | ||||
| 80 | is_depends_on => 0, | ||||
| 81 | ($join_type ? ('join_type' => $join_type) : ()), | ||||
| 82 | 11 | 80µs | 11 | 1.50ms | %{$attrs || {}} }); # spent 1.50ms making 11 calls to DBIx::Class::ResultSourceProxy::add_relationship, avg 136µs/call |
| 83 | 11 | 27µs | 1; | ||
| 84 | } | ||||
| 85 | |||||
| 86 | # spent 829µs (368+461) within DBIx::Class::Relationship::HasOne::_validate_has_one_condition which was called 11 times, avg 75µs/call:
# 11 times (368µs+461µs) by DBIx::Class::Relationship::HasOne::_has_one at line 71, avg 75µs/call | ||||
| 87 | 11 | 4µs | my ($class, $cond ) = @_; | ||
| 88 | |||||
| 89 | 11 | 9µs | return if $ENV{DBIC_DONT_VALIDATE_RELS}; | ||
| 90 | 11 | 7µs | return unless 'HASH' eq ref $cond; | ||
| 91 | 11 | 43µs | foreach my $foreign_id ( keys %$cond ) { | ||
| 92 | 11 | 5µs | my $self_id = $cond->{$foreign_id}; | ||
| 93 | |||||
| 94 | # we can ignore a bad $self_id because add_relationship handles this | ||||
| 95 | # exception | ||||
| 96 | 11 | 68µs | 11 | 36µs | return unless $self_id =~ /^self\.(.*)$/; # spent 36µs making 11 calls to DBIx::Class::Relationship::HasOne::CORE:match, avg 3µs/call |
| 97 | |||||
| 98 | 11 | 22µs | my $key = $1; | ||
| 99 | 11 | 123µs | 11 | 229µs | $class->throw_exception("Defining rel on ${class} that includes '$key' but no such column defined here yet") # spent 229µs making 11 calls to DBIx::Class::ResultSourceProxy::has_column, avg 21µs/call |
| 100 | unless $class->has_column($key); | ||||
| 101 | 11 | 100µs | 11 | 196µs | my $column_info = $class->column_info($key); # spent 196µs making 11 calls to DBIx::Class::ResultSourceProxy::column_info, avg 18µs/call |
| 102 | 11 | 17µs | if ( $column_info->{is_nullable} ) { | ||
| 103 | 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.'); | ||||
| 104 | } | ||||
| 105 | } | ||||
| 106 | } | ||||
| 107 | |||||
| 108 | 1 | 3µs | 1 | 157µs | 1; # spent 157µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__ |
# spent 36µs within DBIx::Class::Relationship::HasOne::CORE:match which was called 11 times, avg 3µs/call:
# 11 times (36µs+0s) by DBIx::Class::Relationship::HasOne::_validate_has_one_condition at line 96, avg 3µs/call |