| 1 | package Data::Model::Schema::Properties; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use base qw(Data::Model::Accessor); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | $Carp::Internal{(__PACKAGE__)}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Class::Trigger qw( pre_insert pre_save post_save post_load pre_update pre_inflate post_inflate pre_deflate post_deflate ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Params::Validate ':all'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Data::Model::Schema; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Data::Model::Schema::Inflate; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Data::Model::Schema::SQL; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | __PACKAGE__->mk_accessors(qw/ driver schema_class model class column columns index unique key options has_inflate has_deflate alias_column aluas_column_revers_map /); | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | our @RESERVED = qw( | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | update save new | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | add_trigger call_trigger remove_trigger | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | my($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | bless { %args }, $class; | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | ▶ | sub new_obj { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_obj: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | $self->{class}->new(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub has_index { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_index: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | $_[0]->{unique}->{$_[1]} || $_[0]->{index}->{$_[1]} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | sub add_keys { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_keys: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | my($self, $key, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | $self->{key} = ref($key) eq 'ARRAY' ? $key : [ $key ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=12.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | for my $name (qw/ unique index /) { | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | ▶ | *{"add_$name"} = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=32.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my($self, $index, $columns, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my $key = $columns || $index; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$columns || $index
MC/DC0%0/2
$columns || $index
$columns
$index
Truth table0%0/3
A || B
A= $columnsB= $index
| |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | Carp::croak sprintf '%s::%s : %s name is require', $self->schema_class, $self->name, $name | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $index or not defined $index
MC/DC0%0/2
ref $index or not defined $index
ref $index
not defined $index
Truth table0%0/3
A or not(B)
A= ref $indexB= not defined $index
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | if ref($index) || !defined $index; | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | $key = [ $key ] unless ref($key) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $self->{$name}->{$index} = $key; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | sub add_column { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_column: called CC=10 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | my($column, $type, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | return $self->add_column_sugar(@_) if $column =~ /^[^\.+]+\.[^\.+]+$/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | Carp::croak "Column can't be called '$column': reserved name" | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | ▶ | if grep { lc $_ eq lc $column } @RESERVED; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | Carp::croak 'The multiplex definition of "require" and the "required" is carried out.' | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | ▶ | if exists $options->{require} && exists $options->{required}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $options->{"require"} and exists $options->{"required"}
MC/DC0%0/2
exists $options->{"require"} and exists $options->{"required"}
exists $options->{"require"}
exists $options->{"required"}
Truth table33%1/3
A and B
A= exists $options->{"require"}B= exists $options->{"required"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | ▶ | if (exists $options->{require}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $options->{required} = delete $options->{require}; | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # validation for $options | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | if ($Data::Model::RUN_VALIDATION) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | my @p = %{ $options }; | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | validate( | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | @p, { | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | size => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | type => SCALAR, | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | regex => qr/\A[0-9]+\z/, | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | required => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | type => BOOLEAN, | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | null => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | type => BOOLEAN, | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | signed => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | type => BOOLEAN, | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | unsigned => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | type => BOOLEAN, | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | decimals => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | type => BOOLEAN, | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | zerofill => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | type => BOOLEAN, | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | binary => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | type => BOOLEAN, | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | ascii => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | type => BOOLEAN, | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | unicode => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | type => BOOLEAN, | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | default => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | type => SCALAR | CODEREF, | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # validation => {}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | auto_increment => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | type => BOOLEAN, | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | inflate => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | type => SCALAR | CODEREF, | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | deflate => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | type => SCALAR | CODEREF, | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | $self->{utf8_columns}->{$column} = 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | ▶ | if delete $self->{_build_tmp}->{utf8_column}->{$column}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | push @{ $self->{columns} }, $column; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | ▶ | $self->{column}->{$column} = +{ | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$type || 'char'
$options || {}
MC/DC0%0/1
$type || 'char'
$type
MC/DC0%0/1
$options || {}
$options
Truth table50%1/2
A
A= $type
Truth table50%1/2
A
A= $options
| |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | type => $type || 'char', | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | options => $options || +{}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub add_utf8_column { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_utf8_column: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my($column) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | $self->{_build_tmp}->{utf8_column} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"_build_tmp"}{"utf8_column"} ||= {}
MC/DC0%0/1
$self->{"_build_tmp"}{"utf8_column"} ||= {}
$self->{"_build_tmp"}{"utf8_column"}
Truth table0%0/2
A
A= $self->{"_build_tmp"}{"utf8_column"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $self->{_build_tmp}->{utf8_column}->{$column} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $self->add_column(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub add_alias_column { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_alias_column: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my($base_name, $alias_name, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | $self->{aluas_column_revers_map}->{$base_name} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"aluas_column_revers_map"}{$base_name} ||= []
MC/DC0%0/1
$self->{"aluas_column_revers_map"}{$base_name} ||= []
$self->{"aluas_column_revers_map"}{$base_name}
Truth table0%0/2
A
A= $self->{"aluas_column_revers_map"}{$base_name}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | push @{ $self->{aluas_column_revers_map}->{$base_name} }, $alias_name; | |||||||||||||||||||||||||||||||||||||||||||||
| 162 | $self->{alias_column}->{$alias_name} = +{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | %{ $args || {} }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args || {}
MC/DC0%0/1
$args || {}
$args
Truth table0%0/2
A
A= $args
| |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | base => $base_name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub add_column_sugar { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_column_sugar: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my $sugar = Data::Model::Schema->get_column_sugar($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | Carp::croak "Undefined column of '$name'" | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | unless exists $sugar->{$name} && $sugar->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $sugar->{$name} and $sugar->{$name}
MC/DC0%0/2
exists $sugar->{$name} and $sugar->{$name}
exists $sugar->{$name}
$sugar->{$name}
Truth table0%0/3
A and B
A= exists $sugar->{$name}B= $sugar->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $conf = $sugar->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | my %clone = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | type => $conf->{type}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | options => +{ %{ $conf->{options} } }, | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $column; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | if (@_ == 0 || ref($_[0])) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 0 or ref $_[0]
MC/DC0%0/2
@_ == 0 or ref $_[0]
@_ == 0
ref $_[0]
Truth table0%0/3
A or B
A= @_ == 0B= ref $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $model; | |||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ($model, $column) = split /\./, $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | unless ($self->{model} eq $model) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $column = join '_', $model, $column; | |||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $column = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if (@_ && ref($_[0]) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ and ref $_[0] eq "HASH"
@_
ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= @_B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $clone{options} = +{ %{ $clone{options} }, %{ ( shift ) } } | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if (my $alias_args = delete $clone{options}->{alias}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | my $rename_map = delete $clone{options}->{alias_rename} || {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $clone{'options'}{'alias_rename'} || {}
MC/DC0%0/1
delete $clone{'options'}{'alias_rename'} || {}
delete $clone{'options'}{'alias_rename'}
Truth table0%0/2
A
A= delete $clone{'options'}{'alias_rename'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | while (my($alias_name, $args) = each %{ $alias_args }) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | $self->add_alias_column($column, $rename_map->{$alias_name} || $alias_name, $args); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$rename_map->{$alias_name} || $alias_name
MC/DC0%0/2
$rename_map->{$alias_name} || $alias_name
$rename_map->{$alias_name}
$alias_name
Truth table0%0/3
A || B
A= $rename_map->{$alias_name}B= $alias_name
| |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | $self->{utf8_columns}->{$column} = 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if delete $self->{_build_tmp}->{utf8_column}->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $self->add_column($column, $clone{type}, $clone{options}); | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub add_options { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_options: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | if (ref($_[0]) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $self->{options} = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | } elsif (!(@_ % 2)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | while (my($key, $value) = splice @_, 0, 2) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $self->{options}->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 4 | ▶ | sub column_names { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
column_names: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | @{ $self->{columns} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 5 | ▶ | sub column_type { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
column_type: called CC=4 SCAR=17.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 5 | my($self, $column) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 224 | 5 | ▶ | return 'char' unless $column && $self->{column}->{$column} && $self->{column}->{$column}->{type}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$column and $self->{"column"}{$column} and $self->{"column"}{$column}{"type"}
$column and $self->{"column"}{$column}
MC/DC0%0/3
$column and $self->{"column"}{$column} and $self->{"column"}{$column}{"type"}
$column
$self->{"column"}{$column}
$self->{"column"}{$column}{"type"}
Truth table25%1/4
A and B and C
A= $columnB= $self->{"column"}{$column}C= $self->{"column"}{$column}{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 5 | $self->{column}->{$column}->{type}; | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | ▶ | sub column_options { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
column_options: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | my($self, $column) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | 2 | ▶ | $self->{column}->{$column}->{options} || +{}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | ▶ | sub setup_inflate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_inflate: called CC=18 SCAR=48.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | $self->{inflate_columns} = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | $self->{deflate_columns} = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | ▶ | while (my($column, $data) = each %{ $self->{column} }) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | my $opts = $data->{options}; | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | my $inflate = $opts->{inflate}; | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | ▶ | if ($inflate && ref($inflate) ne 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$inflate and ref $inflate ne "CODE"
MC/DC0%0/2
$inflate and ref $inflate ne "CODE"
$inflate
ref $inflate ne "CODE"
Truth table33%1/3
A and B
A= $inflateB= ref $inflate ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $opts->{inflate} = Data::Model::Schema::Inflate->get_inflate($inflate); | |||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $opts->{deflate} = $inflate; | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $inflate = $opts->{inflate}; | |||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | ▶ | if (ref($inflate) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | push @{ $self->{inflate_columns} }, $column; | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $self->{has_inflate} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | delete $opts->{inflate}; | |||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | my $deflate = $opts->{deflate}; | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | ▶ | if ($deflate && ref($deflate) ne 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$deflate and ref $deflate ne "CODE"
MC/DC0%0/2
$deflate and ref $deflate ne "CODE"
$deflate
ref $deflate ne "CODE"
Truth table33%1/3
A and B
A= $deflateB= ref $deflate ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $opts->{deflate} = Data::Model::Schema::Inflate->get_deflate($deflate); | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $deflate = $opts->{deflate}; | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | ▶ | if (ref($deflate) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | push @{ $self->{deflate_columns} }, $column; | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $self->{has_deflate} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | delete $opts->{deflate}; | |||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1 | ▶ | if (scalar(%{ $self->{utf8_columns} })) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $self->{has_inflate} = $self->{has_deflate} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my @columns = keys %{ $self->{column} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $self->{inflate_columns} = \@columns; | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $self->{deflate_columns} = \@columns; | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # for alias | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | ▶ | while (my($base, $list) = each %{ $self->{aluas_column_revers_map} }) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | for my $alias (@{ $list }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my $args = $self->{alias_column}->{$alias}; | |||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my $inflate = $args->{inflate}; | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if ($inflate && ref($inflate) ne 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$inflate and ref $inflate ne "CODE"
MC/DC0%0/2
$inflate and ref $inflate ne "CODE"
$inflate
ref $inflate ne "CODE"
Truth table0%0/3
A and B
A= $inflateB= ref $inflate ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $args->{inflate} = Data::Model::Schema::Inflate->get_inflate($inflate); | |||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $args->{deflate} = Data::Model::Schema::Inflate->get_deflate($inflate); | |||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $inflate_code = $args->{inflate}; | |||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my $is_utf8 = $args->{is_utf8}; | |||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | my $charset = $args->{charset} || 'utf8'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'charset'} || 'utf8'
MC/DC0%0/1
$args->{'charset'} || 'utf8'
$args->{'charset'}
Truth table0%0/2
A
A= $args->{'charset'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # make inflate2alias | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $code; | |||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | if ($is_utf8 && $inflate_code) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$is_utf8 and $inflate_code
MC/DC0%0/2
$is_utf8 and $inflate_code
$is_utf8
$inflate_code
Truth table0%0/3
A and B
A= $is_utf8B= $inflate_code
| |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | $code = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $_[0]->{alias_values}->{$alias} = $inflate_code->( Encode::decode( $charset, $_[0]->{column_values}->{$base} ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 296 | } elsif ($is_utf8) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | $code = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $_[0]->{alias_values}->{$alias} = Encode::decode( $charset, $_[0]->{column_values}->{$base} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 300 | } elsif ($inflate_code) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | $code = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $_[0]->{alias_values}->{$alias} = $inflate_code->( $_[0]->{column_values}->{$base} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 304 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | $code = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $_[0]->{alias_values}->{$alias} = $_[0]->{column_values}->{$base}; | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $args->{inflate2alias} = $code; | |||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 4 | ▶ | sub inflate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inflate: called CC=12 SCAR=49.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 4 | ▶ | if ($_[0]->{has_inflate}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my($self, $columns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my $orig_columns; | |||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if (ref($columns) eq $self->{class}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $orig_columns = $columns; | |||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $columns = $columns->{column_values}; | |||||||||||||||||||||||||||||||||||||||||||||
| 321 | } elsif (ref($columns) ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | Carp::croak "required types 'HASH' or '$self->{class}' of inflate"; | |||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $self->call_trigger('pre_inflate', $columns, $orig_columns); | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | for my $column (@{ $self->{inflate_columns} }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | next unless defined $columns->{$column}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my $opts = $self->{column}->{$column}->{options}; | |||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | my $val = $columns->{$column}; | |||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | if ($self->{utf8_columns}->{$column}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | my $charset = $opts->{charset} || 'utf8'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts->{'charset'} || 'utf8'
MC/DC0%0/1
$opts->{'charset'} || 'utf8'
$opts->{'charset'}
Truth table0%0/2
A
A= $opts->{'charset'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $val = Encode::decode($charset, $val); | |||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | $val = $opts->{inflate}->($val) if ref($opts->{inflate}) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||
| 339 | $orig_columns->{original_cols}->{$column} ||= $orig_columns->{column_values}->{$column} | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | if $orig_columns && $columns->{$column} ne $val; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$orig_columns and $columns->{$column} ne $val
$orig_columns->{"original_cols"}{$column} ||= $orig_columns->{"column_values"}{$column}
MC/DC0%0/2
$orig_columns and $columns->{$column} ne $val
$orig_columns
$columns->{$column} ne $val
MC/DC0%0/2
$orig_columns->{"original_cols"}{$column} ||= $orig_columns->{"column_values"}{$column}
$orig_columns->{"original_cols"}{$column}
$orig_columns->{"column_values"}{$column}
Truth table0%0/3
A and B
A= $orig_columnsB= $columns->{$column} ne $val
Truth table0%0/3
A ||= B
A= $orig_columns->{"original_cols"}{$column}B= $orig_columns->{"column_values"}{$column}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $columns->{$column} = $val; | |||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $self->call_trigger('post_inflate', $columns, $orig_columns); | |||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 2 | ▶ | sub deflate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deflate: called CC=9 SCAR=43.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 2 | ▶ | return unless $_[0]->{has_deflate}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my($self, $columns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my $orig_columns; | |||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | if (ref($columns) eq $self->{class}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $orig_columns = $columns; | |||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $columns = $columns->{column_values}; | |||||||||||||||||||||||||||||||||||||||||||||
| 355 | } elsif (ref($columns) ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | Carp::croak "required types 'HASH' or '$self->{class}' of inflate"; | |||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $self->call_trigger('pre_deflate', $columns, $orig_columns); | |||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | for my $column (@{ $self->{deflate_columns} }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | next unless defined $columns->{$column}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my $opts = $self->{column}->{$column}->{options}; | |||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my $val = $columns->{$column}; | |||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | $val = $opts->{deflate}->($val) if ref($opts->{deflate}) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | if ($self->{utf8_columns}->{$column}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | my $charset = $opts->{charset} || 'utf8'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts->{'charset'} || 'utf8'
MC/DC0%0/1
$opts->{'charset'} || 'utf8'
$opts->{'charset'}
Truth table0%0/2
A
A= $opts->{'charset'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $val = Encode::encode($charset, $val); | |||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $columns->{$column} = $val; | |||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | $self->call_trigger('post_deflate', $columns, $orig_columns); | |||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 2 | ▶ | sub set_default { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_default: called CC=6 SCAR=27.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 2 | my($self, $columns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 2 | ▶ | while (my($name, $conf) = each %{ $self->{column} }) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 2 | ▶ | next if exists $columns->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | next unless exists $conf->{options}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | next unless exists $conf->{options}->{default}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | my $default = $conf->{options}->{default}; | |||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if (ref($default) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $columns->{$name} = $default->($self, $columns); | |||||||||||||||||||||||||||||||||||||||||||||
| 387 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | $columns->{$name} = $default; | |||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 2 | ▶ | sub get_key_array_by_hash { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_key_array_by_hash: called CC=7 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 2 | my($self, $hash, $index) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 2 | my $key; | |||||||||||||||||||||||||||||||||||||||||||||
| 397 | 2 | ▶ | $key = $self->{unique}->{$index} || $self->{index}->{$index} if $index; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{'unique'}{$index} || $self->{'index'}{$index}
MC/DC0%0/2
$self->{'unique'}{$index} || $self->{'index'}{$index}
$self->{'unique'}{$index}
$self->{'index'}{$index}
Truth table0%0/3
A || B
A= $self->{'unique'}{$index}B= $self->{'index'}{$index}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 2 | ▶ | $key ||= $self->{key}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$key ||= $self->{"key"}
MC/DC0%0/2
$key ||= $self->{"key"}
$key
$self->{"key"}
Truth table33%1/3
A ||= B
A= $keyB= $self->{"key"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 2 | ▶ | $key = [ $key ] unless ref($key) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 2 | my @keys; | |||||||||||||||||||||||||||||||||||||||||||||
| 402 | 2 | for my $key (@{ $key }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 403 | 2 | ▶ | last unless defined $hash->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 2 | push @keys, $hash->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 2 | \@keys; | |||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 2 | ▶ | sub get_columns_hash_by_key_array_and_hash { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_columns_hash_by_key_array_and_hash: called CC=8 SCAR=24.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 2 | my($self, $hash, $array, $index) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 411 | 2 | my $ret = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # by column | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 2 | for my $column (keys %{ $self->{column} }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 415 | 2 | ▶ | next unless exists $hash->{$column}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | $ret->{$column} = $hash->{$column}; | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # by key | ||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 2 | my $key; | |||||||||||||||||||||||||||||||||||||||||||||
| 421 | 2 | ▶ | $key = $self->{unique}->{$index} || $self->{index}->{$index} || Carp::croak "Cannot find index '$index'" if $index; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$self->{'unique'}{$index} || $self->{'index'}{$index} || Carp::croak("Cannot find index '${index}'")
$self->{"unique"}{$index} or $self->{"index"}{$index}
MC/DC0%0/2
$self->{'unique'}{$index} || $self->{'index'}{$index} || Carp::croak("Cannot find index '${index}'")
$self->{"unique"}{$index}
$self->{"index"}{$index}
Truth table0%0/3
A or B
A= $self->{"unique"}{$index}B= $self->{"index"}{$index}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 2 | ▶ | $key ||= $self->{key}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$key ||= $self->{"key"}
MC/DC0%0/2
$key ||= $self->{"key"}
$key
$self->{"key"}
Truth table33%1/3
A ||= B
A= $keyB= $self->{"key"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 2 | ▶ | $key = [ $key ] unless ref($key) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 2 | @{ $ret }{@{ $key }} = @{ $array }; | |||||||||||||||||||||||||||||||||||||||||||||
| 426 | 2 | $ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 1 | ▶ | sub sql { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sql: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 432 | 1 | ▶ | $self->{sql} ||= Data::Model::Schema::SQL->new($self); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"sql"} ||= "Data::Model::Schema::SQL"->new($self)
MC/DC0%0/2
$self->{"sql"} ||= "Data::Model::Schema::SQL"->new($self)
$self->{"sql"}
"Data::Model::Schema::SQL"->new($self)
Truth table33%1/3
A ||= B
A= $self->{"sql"}B= "Data::Model::Schema::SQL"->new($self)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||