Filename | /usr/share/perl5/DBIx/Class/Relationship/Accessor.pm |
Statements | Executed 0 statements in 0s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
319 | 1 | 1 | 9.81ms | 83.0ms | add_relationship_accessor | DBIx::Class::Relationship::Accessor::
319 | 1 | 1 | 6.00ms | 93.6ms | register_relationship | DBIx::Class::Relationship::Accessor::
1 | 1 | 1 | 16µs | 26µs | BEGIN@4 | DBIx::Class::Relationship::Accessor::
1 | 1 | 1 | 9µs | 38µs | BEGIN@7 | DBIx::Class::Relationship::Accessor::
1 | 1 | 1 | 9µs | 16µs | BEGIN@5 | DBIx::Class::Relationship::Accessor::
1 | 1 | 1 | 8µs | 57µs | BEGIN@6 | DBIx::Class::Relationship::Accessor::
1 | 1 | 1 | 8µs | 126µs | BEGIN@8 | DBIx::Class::Relationship::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:72] | DBIx::Class::Relationship::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:94] | DBIx::Class::Relationship::Accessor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package # hide from PAUSE | ||||
2 | DBIx::Class::Relationship::Accessor; | ||||
3 | |||||
4 | 2 | 35µs | # spent 26µs (16+10) within DBIx::Class::Relationship::Accessor::BEGIN@4 which was called:
# once (16µs+10µs) by Class::C3::Componentised::ensure_class_loaded at line 4 # spent 26µs making 1 call to DBIx::Class::Relationship::Accessor::BEGIN@4
# spent 10µs making 1 call to strict::import | ||
5 | 2 | 23µs | # spent 16µs (9+7) within DBIx::Class::Relationship::Accessor::BEGIN@5 which was called:
# once (9µs+7µs) by Class::C3::Componentised::ensure_class_loaded at line 5 # spent 16µs making 1 call to DBIx::Class::Relationship::Accessor::BEGIN@5
# spent 7µs making 1 call to warnings::import | ||
6 | 2 | 105µs | # spent 57µs (8+49) within DBIx::Class::Relationship::Accessor::BEGIN@6 which was called:
# once (8µs+49µs) by Class::C3::Componentised::ensure_class_loaded at line 6 # spent 57µs making 1 call to DBIx::Class::Relationship::Accessor::BEGIN@6
# spent 49µs making 1 call to DBIx::Class::Carp::import | ||
7 | 2 | 66µs | # spent 38µs (9+29) within DBIx::Class::Relationship::Accessor::BEGIN@7 which was called:
# once (9µs+29µs) by Class::C3::Componentised::ensure_class_loaded at line 7 # spent 38µs making 1 call to DBIx::Class::Relationship::Accessor::BEGIN@7
# spent 29µs making 1 call to Exporter::import | ||
8 | 2 | 245µs | # spent 126µs (8+118) within DBIx::Class::Relationship::Accessor::BEGIN@8 which was called:
# once (8µs+118µs) by Class::C3::Componentised::ensure_class_loaded at line 8 # spent 126µs making 1 call to DBIx::Class::Relationship::Accessor::BEGIN@8
# spent 118µs making 1 call to namespace::clean::import | ||
9 | |||||
10 | our %_pod_inherit_config = | ||||
11 | ( | ||||
12 | class_map => { 'DBIx::Class::Relationship::Accessor' => 'DBIx::Class::Relationship' } | ||||
13 | ); | ||||
14 | |||||
15 | # spent 93.6ms (6.00+87.6) within DBIx::Class::Relationship::Accessor::register_relationship which was called 319 times, avg 293µs/call:
# 319 times (6.00ms+87.6ms) by DBIx::Class::ResultSourceProxy::add_relationship at line 46 of DBIx/Class/ResultSourceProxy.pm, avg 293µs/call | ||||
16 | my ($class, $rel, $info) = @_; | ||||
17 | 319 | 83.0ms | if (my $acc_type = $info->{attrs}{accessor}) { # spent 83.0ms making 319 calls to DBIx::Class::Relationship::Accessor::add_relationship_accessor, avg 260µs/call | ||
18 | $class->add_relationship_accessor($rel => $acc_type); | ||||
19 | } | ||||
20 | 319 | 3.23ms | $class->next::method($rel => $info); # spent 3.23ms making 319 calls to next::method, avg 10µs/call | ||
21 | } | ||||
22 | |||||
23 | # spent 83.0ms (9.81+73.2) within DBIx::Class::Relationship::Accessor::add_relationship_accessor which was called 319 times, avg 260µs/call:
# 319 times (9.81ms+73.2ms) by DBIx::Class::Relationship::Accessor::register_relationship at line 17, avg 260µs/call | ||||
24 | my ($class, $rel, $acc_type) = @_; | ||||
25 | |||||
26 | 106 | 5.21ms | if ($acc_type eq 'single') { # spent 5.08ms making 53 calls to Sub::Quote::quote_sub, avg 96µs/call
# spent 132µs making 53 calls to DBIx::Class::_Util::perlstring, avg 2µs/call | ||
27 | quote_sub "${class}::${rel}" => sprintf(<<'EOC', perlstring $rel); | ||||
28 | my $self = shift; | ||||
29 | |||||
30 | if (@_) { | ||||
31 | $self->set_from_related( %1$s => @_ ); | ||||
32 | return $self->{_relationship_data}{%1$s} = $_[0]; | ||||
33 | } | ||||
34 | elsif (exists $self->{_relationship_data}{%1$s}) { | ||||
35 | return $self->{_relationship_data}{%1$s}; | ||||
36 | } | ||||
37 | else { | ||||
38 | my $relcond = $self->result_source->_resolve_relationship_condition( | ||||
39 | rel_name => %1$s, | ||||
40 | foreign_alias => %1$s, | ||||
41 | self_alias => 'me', | ||||
42 | self_result_object => $self, | ||||
43 | ); | ||||
44 | |||||
45 | return undef if ( | ||||
46 | $relcond->{join_free_condition} | ||||
47 | and | ||||
48 | $relcond->{join_free_condition} ne DBIx::Class::_Util::UNRESOLVABLE_CONDITION | ||||
49 | and | ||||
50 | scalar grep { not defined $_ } values %%{ $relcond->{join_free_condition} || {} } | ||||
51 | and | ||||
52 | $self->result_source->relationship_info(%1$s)->{attrs}{undef_on_null_fk} | ||||
53 | ); | ||||
54 | |||||
55 | my $val = $self->search_related( %1$s )->single; | ||||
56 | return $val unless $val; # $val instead of undef so that null-objects can go through | ||||
57 | |||||
58 | return $self->{_relationship_data}{%1$s} = $val; | ||||
59 | } | ||||
60 | EOC | ||||
61 | } | ||||
62 | elsif ($acc_type eq 'filter') { | ||||
63 | 122 | 1.42ms | $class->throw_exception("No such column '$rel' to filter") # spent 1.42ms making 122 calls to DBIx::Class::ResultSourceProxy::has_column, avg 12µs/call | ||
64 | unless $class->has_column($rel); | ||||
65 | |||||
66 | 122 | 1.90ms | my $f_class = $class->relationship_info($rel)->{class}; # spent 1.90ms making 122 calls to DBIx::Class::ResultSourceProxy::relationship_info, avg 16µs/call | ||
67 | |||||
68 | $class->inflate_column($rel, { | ||||
69 | inflate => sub { | ||||
70 | my ($val, $self) = @_; | ||||
71 | return $self->find_or_new_related($rel, {}, {}); | ||||
72 | }, | ||||
73 | deflate => sub { | ||||
74 | my ($val, $self) = @_; | ||||
75 | $self->throw_exception("'$val' isn't a $f_class") unless $val->isa($f_class); | ||||
76 | |||||
77 | # MASSIVE FIXME - this code assumes we pointed at the PK, but the belongs_to | ||||
78 | # helper does not check any of this | ||||
79 | # fixup the code a bit to make things saner, but ideally 'filter' needs to | ||||
80 | # be deprecated ASAP and removed shortly after | ||||
81 | # Not doing so before 0.08250 however, too many things in motion already | ||||
82 | my ($pk_col, @rest) = $val->result_source->_pri_cols_or_die; | ||||
83 | $self->throw_exception( | ||||
84 | "Relationship '$rel' of type 'filter' can not work with a multicolumn primary key on source '$f_class'" | ||||
85 | ) if @rest; | ||||
86 | |||||
87 | my $pk_val = $val->get_column($pk_col); | ||||
88 | carp_unique ( | ||||
89 | "Unable to deflate 'filter'-type relationship '$rel' (related object " | ||||
90 | . "primary key not retrieved), assuming undef instead" | ||||
91 | ) if ( ! defined $pk_val and $val->in_storage ); | ||||
92 | |||||
93 | return $pk_val; | ||||
94 | }, | ||||
95 | 122 | 39.7ms | }); # spent 39.7ms making 122 calls to DBIx::Class::InflateColumn::inflate_column, avg 325µs/call | ||
96 | } | ||||
97 | elsif ($acc_type eq 'multi') { | ||||
98 | |||||
99 | 144 | 9.70ms | quote_sub "${class}::${rel}_rs", "shift->search_related_rs( $rel => \@_ )"; # spent 9.70ms making 144 calls to Sub::Quote::quote_sub, avg 67µs/call | ||
100 | 144 | 7.50ms | quote_sub "${class}::add_to_${rel}", "shift->create_related( $rel => \@_ )"; # spent 7.50ms making 144 calls to Sub::Quote::quote_sub, avg 52µs/call | ||
101 | 288 | 7.72ms | quote_sub "${class}::${rel}", sprintf( <<'EOC', perlstring $rel ); # spent 7.43ms making 144 calls to Sub::Quote::quote_sub, avg 52µs/call
# spent 295µs making 144 calls to DBIx::Class::_Util::perlstring, avg 2µs/call | ||
102 | DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_WANTARRAY and my $sog = DBIx::Class::_Util::fail_on_internal_wantarray; | ||||
103 | shift->search_related( %s => @_ ) | ||||
104 | EOC | ||||
105 | } | ||||
106 | else { | ||||
107 | $class->throw_exception("No such relationship accessor type '$acc_type'"); | ||||
108 | } | ||||
109 | |||||
110 | } | ||||
111 | |||||
112 | 1 | 135µs | 1; # spent 135µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__ |