| 1 | package ObjectDB::With; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 5 | our $VERSION = '3.27'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | sub new { | ||||||||||||||||||||||||||||
| 9 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | 0 | my (%params) = @_; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | my $self = {}; | |||||||||||||||||||||||||||
| 13 | 0 | bless $self, $class; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | $self->{meta} = $params{meta}; | |||||||||||||||||||||||||||
| 16 | 0 | $self->{with} = $params{with}; | |||||||||||||||||||||||||||
| 17 | $self->{with} = [ $self->{with} ] | ||||||||||||||||||||||||||||
| 18 | 0 | ▶ | if $self->{with} && ref $self->{with} ne 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"with"} and ref $self->{"with"} ne "ARRAY"
MC/DC0%0/2
$self->{"with"} and ref $self->{"with"} ne "ARRAY"
$self->{"with"}
ref $self->{"with"} ne "ARRAY"
Truth table0%0/3
A and B
A= $self->{"with"}B= ref $self->{"with"} ne "ARRAY"
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | my $joins = { join => [] }; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | my %seen; | |||||||||||||||||||||||||||
| 23 | 0 | ▶ | if (my @with = sort grep { defined } @{ $self->{with} || [] }) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 24 | 0 | foreach my $with (@with) { | |||||||||||||||||||||||||||
| 25 | 0 | my $meta = $self->{meta}; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | my $name = $with; | |||||||||||||||||||||||||||
| 28 | 0 | my $columns; | |||||||||||||||||||||||||||
| 29 | 0 | ▶ | if (ref $name eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 0 | $name = $with->{name}; | |||||||||||||||||||||||||||
| 31 | 0 | $columns = $with->{columns}; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | my @parts = split /[.]/xms, $name; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | my $seen = q{}; | |||||||||||||||||||||||||||
| 37 | 0 | my $parent_join = $joins; | |||||||||||||||||||||||||||
| 38 | 0 | foreach my $part (@parts) { | |||||||||||||||||||||||||||
| 39 | 0 | $seen .= q{.} . $part; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | my $rel = $meta->get_relationship($part); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ($seen{$seen}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | $parent_join = $seen{$seen}; | |||||||||||||||||||||||||||
| 45 | 0 | $meta = $rel->class->meta; | |||||||||||||||||||||||||||
| 46 | 0 | next; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | my $parent_as = $parent_join->{as}; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | my $name_prefix = $parent_as ? $parent_as . '_' : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | my @joins = $rel->to_source( | ||||||||||||||||||||||||||||
| 53 | table => $parent_join->{as}, | ||||||||||||||||||||||||||||
| 54 | 0 | name_prefix => $name_prefix | |||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | foreach my $join (@joins) { | |||||||||||||||||||||||||||
| 58 | 0 | ▶ | push @{ $parent_join->{join} }, | ||||||||||||||||||||||||||
|
Condition0%0/3
$columns || $join->{'columns'}
MC/DC0%0/2
$columns || $join->{'columns'}
$columns
$join->{'columns'}
Truth table0%0/3
A || B
A= $columnsB= $join->{'columns'}
| |||||||||||||||||||||||||||||
| 59 | { | ||||||||||||||||||||||||||||
| 60 | source => $join->{table}, | ||||||||||||||||||||||||||||
| 61 | rel_name => $join->{as}, | ||||||||||||||||||||||||||||
| 62 | as => $name_prefix . $join->{as}, | ||||||||||||||||||||||||||||
| 63 | on => $join->{constraint}, | ||||||||||||||||||||||||||||
| 64 | op => $join->{join}, | ||||||||||||||||||||||||||||
| 65 | columns => $columns || $join->{columns}, | ||||||||||||||||||||||||||||
| 66 | 0 | join => [] | |||||||||||||||||||||||||||
| 67 | }; | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | $parent_join = $parent_join->{join}->[-1]; | |||||||||||||||||||||||||||
| 71 | 0 | $seen{$seen} = $parent_join; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | $meta = $rel->class->meta; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | $self->{joins} = $joins->{join}; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | return $self; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | sub to_joins { | ||||||||||||||||||||||||||||
| 84 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
to_joins: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | return $self->{joins}; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 5 | 1; | |||||||||||||||||||||||||||