| 1 | package EntityModel::Query::Table; | ||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||
| 3 | 37 | $EntityModel::Query::Table::VERSION = '0.102'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | 37 | ▶ | use EntityModel::Class { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 37 | '_isa' => [qw(EntityModel::Query::Base)], | |||||||||||||||||||||||||||
| 7 | 'entity' => { type => 'EntityModel::Entity', defer => 1 }, | ||||||||||||||||||||||||||||
| 8 | 'table' => 'string', | ||||||||||||||||||||||||||||
| 9 | 'alias' => 'string', | ||||||||||||||||||||||||||||
| 10 | 37 | }; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | EntityModel::Query::Table | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =head1 VERSION | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | version 0.102 | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | See L<Entitymodel::Query>. | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | See L<Entitymodel::Query>. | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =cut | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 METHODS | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head2 new | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | =cut | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 10 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | 10 | my $class = shift; | |||||||||||||||||||||||||||
| 40 | 10 | my $self = bless { }, $class; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # Handle plain value | ||||||||||||||||||||||||||||
| 43 | 10 | ▶ | if(@_ == 1 && !ref $_[0]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and not ref $_[0]
MC/DC0%0/2
@_ == 1 and not ref $_[0]
@_ == 1
not ref $_[0]
Truth table33%1/3
A and not(B)
A= @_ == 1B= not ref $_[0]
| |||||||||||||||||||||||||||||
| 44 | 10 | $self->table($_[0]); | |||||||||||||||||||||||||||
| 45 | } else { | ||||||||||||||||||||||||||||
| 46 | 0 | $self->entity($_[0]); | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 10 | return $self; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head2 asString | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =cut | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 20 | ▶ | sub asString { | ||||||||||||||||||||||||||
|
Subroutine
asString: called CC=5 SCAR=23.4
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 20 | my $self = shift; | |||||||||||||||||||||||||||
| 58 | 20 | my $str = ''; | |||||||||||||||||||||||||||
| 59 | 20 | ▶ | if($self->table) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 20 | $str = $self->table; | |||||||||||||||||||||||||||
| 61 | } else { | ||||||||||||||||||||||||||||
| 62 | 0 | ▶ | return $self->entity unless ref($self->entity); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if(ref $self->entity eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | my ($alias, $t) = %{$self->entity}; | |||||||||||||||||||||||||||
| 65 | 0 | return "$t as $alias"; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | 0 | return '"' . $self->entity->schema . '"."' . $self->entity->name . '"'; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 20 | ▶ | $str .= ' as ' . $self->alias if $self->alias; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 20 | return $str; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 37 | 1; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | __END__ | ||||||||||||||||||||||||||||