« blib/lib/ObjectDB/Related/OneToOne.pm
↑ Summary
blib/lib/ObjectDB/Meta/Relationship/OneToMany.pm »
| 1 | package ObjectDB::Quoter; | ||||||||||
| 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 | 5 | ▶ | use base 'SQL::Composer::Quoter'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 5 | ▶ | use List::Util qw(first); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | sub new { | ||||||||||
| 13 | 0 | ▶ | my $self = shift->SUPER::new(@_); | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 14 | 0 | my (%params) = @_; | |||||||||
| 15 | |||||||||||
| 16 | 0 | $self->{meta} = $params{meta}; | |||||||||
| 17 | 0 | $self->{with} = []; | |||||||||
| 18 | |||||||||||
| 19 | 0 | return $self; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | sub quote { | ||||||||||
| 23 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
quote: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||
| 24 | 0 | my ($column, $prefix) = @_; | |||||||||
| 25 | |||||||||||
| 26 | 0 | my @parts = split /[.]/xsm, $column; | |||||||||
| 27 | 0 | $column = pop @parts; | |||||||||
| 28 | |||||||||||
| 29 | 0 | my $meta = $self->{meta}; | |||||||||
| 30 | 0 | my $rel_table; | |||||||||
| 31 | my $name; | ||||||||||
| 32 | 0 | foreach my $part (@parts) { | |||||||||
| 33 | 0 | my $relationship = $meta->get_relationship($part); | |||||||||
| 34 | |||||||||||
| 35 | 0 | ▶ | $name = $name ? $name . '_' . $relationship->name : $relationship->name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | $rel_table = $relationship->class->meta->table; | |||||||||
| 37 | 0 | $meta = $relationship->class->meta; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | if ($rel_table) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | $column = $name . q{.} . $column; | |||||||||
| 42 | |||||||||||
| 43 | 0 | my $with = join q{.}, @parts; | |||||||||
| 44 | 0 | push @{ $self->{with} }, $with | |||||||||
| 45 | 0 | ▶ | unless first { $_ eq $with } @{ $self->{with} }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 0 | return $self->SUPER::quote($column, $prefix); | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | sub with { | ||||||||||
| 52 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
with: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | return @{ $self->{with} || [] }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 5 | 1; | |||||||||