| 1 | package Mojolicious::Plugin::Form::Base; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use Mojo::Base -base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | has 'elements'; | |||||||||||||||||||||||||||
| 7 | 2 | has 'ordered_elements'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 0 | ▶ | has 'element_info' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 10 | 0 | my ($self, $element) = @_; | |||||||||||||||||||||||||||
| 11 | 0 | return $self->elements->{$element}; | |||||||||||||||||||||||||||
| 12 | 2 | }; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 2 | has 'id_field'; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | has 'name_field'; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | has 'order_by'; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 2 | has 'form_debug' => 0; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub add_elements { | ||||||||||||||||||||||||||
|
Subroutine
add_elements: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 0 | my ($self, @elems) = @_; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | my @added; | |||||||||||||||||||||||||||
| 26 | 0 | my $elements = $self->elements; | |||||||||||||||||||||||||||
| 27 | 0 | ▶ | while (my $el = shift @elems) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 0 | my $element_info = {}; | |||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ($el =~ s/^\+//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 0 | $element_info = $self->element_info($el); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # If next entry is { ... } use that for the info, if not | ||||||||||||||||||||||||||||
| 34 | # use an empty hashref | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if (ref $elems[0]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | my $new_info = shift(@elems); | |||||||||||||||||||||||||||
| 37 | 0 | %$element_info = (%$element_info, %$new_info); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 0 | ▶ | push(@added, $el) unless exists $elements->{$el}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | $elements->{$el} = $element_info; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 0 | push @{$self->ordered_elements}, @added; | |||||||||||||||||||||||||||
| 43 | 0 | return $self; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub from_schema { | ||||||||||||||||||||||||||
|
Subroutine
from_schema: not called CC=21 SCAR=61.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 47 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 48 | 0 | my $schema = shift; | |||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $source = shift || $self->name; | ||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $self->name
MC/DC0%0/2
shift() || $self->name
shift()
$self->name
Truth table0%0/3
A || B
A= shift()B= $self->name
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | $self->order_by || $self->order_by($self->order_field($schema, $source)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | my $columns = [$schema->source($source)->columns]; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | #my $result = $schema->resultset($source)->single({$order => $id}); | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | my $columns_info = $schema->source($source)->columns_info($columns); | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | # TODO: smarter | ||||||||||||||||||||||||||||
| 60 | #my $primary_columns = [$schema->source($source)->primary_columns]; | ||||||||||||||||||||||||||||
| 61 | #$self->id_field($primary_columns->[0]); | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | my ($id_field, $name_field) = $self->id_and_name($schema, $source); | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | $self->id_field || $self->id_field($id_field); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | $self->name_field || $self->name_field($name_field); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | my $relationships = [ $schema->source($source)->relationships ]; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | print STDERR '$relationships: ', Dumper($relationships), "\n" if $self->form_debug; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | my $rel_elements; | |||||||||||||||||||||||||||
| 72 | 0 | for my $relation (@$relationships) { | |||||||||||||||||||||||||||
| 73 | 0 | my $relationship = $self->related($schema, $source, $relation); | |||||||||||||||||||||||||||
| 74 | 0 | ▶ | $rel_elements->{$relation} = $relationship if $relationship; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | my $rel_multi; | |||||||||||||||||||||||||||
| 78 | 0 | for my $relation (@$relationships) { | |||||||||||||||||||||||||||
| 79 | 0 | my $relationship = $self->multi_related($schema, $source, $relation); | |||||||||||||||||||||||||||
| 80 | 0 | ▶ | $rel_multi->{$relation} = $relationship if $relationship; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | $self->elements || $self->elements({}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | $self->ordered_elements || $self->ordered_elements([]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | for my $column (@$columns) { | |||||||||||||||||||||||||||
| 87 | 0 | my $element; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if (my $rel_element = $self->exchanges_field($rel_elements, $column)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 0 | $element = $rel_elements->{$rel_element}; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | else { | ||||||||||||||||||||||||||||
| 93 | 0 | my $type = $self->type($columns_info->{$column}->{data_type}); | |||||||||||||||||||||||||||
| 94 | 0 | ▶ | my $required = $columns_info->{$column}->{is_nullable} ? '' : 'required'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | $element = { | |||||||||||||||||||||||||||
| 97 | 'type' => $type, | ||||||||||||||||||||||||||||
| 98 | 'name' => $column, | ||||||||||||||||||||||||||||
| 99 | 'required' => $required, | ||||||||||||||||||||||||||||
| 100 | }; | ||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if (exists $columns_info->{$column}->{default_value} && $columns_info->{$column}->{default_value}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $columns_info->{$column}{"default_value"} and $columns_info->{$column}{"default_value"}
MC/DC0%0/2
exists $columns_info->{$column}{"default_value"} and $columns_info->{$column}{"default_value"}
exists $columns_info->{$column}{"default_value"}
$columns_info->{$column}{"default_value"}
Truth table0%0/3
A and B
A= exists $columns_info->{$column}{"default_value"}B= $columns_info->{$column}{"default_value"}
| |||||||||||||||||||||||||||||
| 102 | 0 | $element->{'default'} = $columns_info->{$column}->{default_value}; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if ($column eq $self->id_field) { $element->{'hidden'} = 1; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | $self->elements->{$column} = $element; | |||||||||||||||||||||||||||
| 109 | 0 | push @{$self->ordered_elements}, $column; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 0 | for my $multi (keys %$rel_multi) { | |||||||||||||||||||||||||||
| 113 | 0 | $self->elements->{$multi} = $rel_multi->{$multi}; | |||||||||||||||||||||||||||
| 114 | 0 | push @{$self->ordered_elements}, $multi; | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | print STDERR 'id_field: ',$self->id_field,' name_field: ',$self->name_field,"\n" if $self->form_debug; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 0 | ▶ | print STDERR 'elements: ',Dumper($self->elements),"\n" if $self->form_debug; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 0 | return $self; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub exchanges_field { | ||||||||||||||||||||||||||
|
Subroutine
exchanges_field: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 123 | 0 | my ($self, $rel_elements, $column) = @_; | |||||||||||||||||||||||||||
| 124 | 0 | for my $rel_element (keys %$rel_elements) { | |||||||||||||||||||||||||||
| 125 | 0 | ▶ | if (exists $rel_elements->{$rel_element}->{'exchanges_field'} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $rel_elements->{$rel_element}{"exchanges_field"} and $rel_elements->{$rel_element}{"exchanges_field"} eq $column
MC/DC0%0/2
exists $rel_elements->{$rel_element}{"exchanges_field"} and $rel_elements->{$rel_element}{"exchanges_field"} eq $column
exists $rel_elements->{$rel_element}{"exchanges_field"}
$rel_elements->{$rel_element}{"exchanges_field"} eq $column
Truth table0%0/3
A and B
A= exists $rel_elements->{$rel_element}{"exchanges_field"}B= $rel_elements->{$rel_element}{"exchanges_field"} eq $column
| |||||||||||||||||||||||||||||
| 126 | && $rel_elements->{$rel_element}->{'exchanges_field'} eq $column) | ||||||||||||||||||||||||||||
| 127 | { | ||||||||||||||||||||||||||||
| 128 | 0 | return $rel_element; | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | 0 | return; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub related { | ||||||||||||||||||||||||||
|
Subroutine
related: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 135 | 0 | my ($self, $schema, $source, $relation) = @_; | |||||||||||||||||||||||||||
| 136 | 0 | ▶ | return undef unless $source; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | #'cond' => { 'foreign.group_id' => 'self.global_role_id' }, | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 0 | my $rel_info = $schema->source($source)->relationship_info($relation); | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | # print STDERR '$rel_info: ', Dumper($rel_info), "\n"; | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | # TODO: accessor 'multi' (???) | ||||||||||||||||||||||||||||
| 145 | 0 | ▶ | return undef unless ($rel_info->{attrs}->{accessor} eq 'single'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | my $rel_source = | ||||||||||||||||||||||||||||
| 148 | 0 | $schema->source($source)->related_source($relation)->{'source_name'}; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | my @rel_fields = $self->id_and_name($schema, $rel_source); | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | my @conditions = %{$rel_info->{cond}}; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | my @self_fields = map { /(\w+)$/; $1 } grep {/^(self\.|)(\w+)$/} @conditions; | |||||||||||||||||||||||||||
| 155 | my @foreign_fields = | ||||||||||||||||||||||||||||
| 156 | 0 | map { /(\w+)$/; $1 } grep {/^(foreign\.|)(\w+)$/} @conditions; | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | my $field_to_exchange = $self_fields[0]; | |||||||||||||||||||||||||||
| 159 | 0 | my $rel_key = $foreign_fields[0]; | |||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 0 | my ($name_field) = grep { $_ !~ /^$rel_key$/ } @rel_fields; | |||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 0 | my $related_element = { | |||||||||||||||||||||||||||
| 164 | 'type' => 'Block', | ||||||||||||||||||||||||||||
| 165 | 'nested_name' => $relation, | ||||||||||||||||||||||||||||
| 166 | 'exchanges_field' => $field_to_exchange, | ||||||||||||||||||||||||||||
| 167 | 'key' => $rel_key, | ||||||||||||||||||||||||||||
| 168 | 'elements' => [ | ||||||||||||||||||||||||||||
| 169 | { | ||||||||||||||||||||||||||||
| 170 | 'type' => 'Text', | ||||||||||||||||||||||||||||
| 171 | 'name' => $name_field, | ||||||||||||||||||||||||||||
| 172 | }, | ||||||||||||||||||||||||||||
| 173 | ], | ||||||||||||||||||||||||||||
| 174 | }; | ||||||||||||||||||||||||||||
| 175 | 0 | return $related_element; | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | sub multi_related { | ||||||||||||||||||||||||||
|
Subroutine
multi_related: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 179 | 0 | my ($self, $schema, $source, $relation) = @_; | |||||||||||||||||||||||||||
| 180 | 0 | ▶ | return undef unless $source; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | #'cond' => { 'foreign.group_id' => 'self.global_role_id' }, | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | my $rel_info = $schema->source($source)->relationship_info($relation); | |||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | # print STDERR '$rel_info: ', Dumper($rel_info), "\n"; | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | # TODO: accessor 'multi' (???) | ||||||||||||||||||||||||||||
| 189 | 0 | ▶ | return undef unless ($rel_info->{attrs}->{accessor} eq 'multi'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | my $rel_source = | ||||||||||||||||||||||||||||
| 192 | 0 | $schema->source($source)->related_source($relation)->{'source_name'}; | |||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 0 | my @rel_fields = $self->id_and_name($schema, $rel_source); | |||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 0 | my @conditions = %{$rel_info->{cond}}; | |||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 0 | my @self_fields = map { /(\w+)$/; $1 } grep {/^(self\.|)(\w+)$/} @conditions; | |||||||||||||||||||||||||||
| 199 | my @foreign_fields = | ||||||||||||||||||||||||||||
| 200 | 0 | map { /(\w+)$/; $1 } grep {/^(foreign\.|)(\w+)$/} @conditions; | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | my $field_to_exchange = $self_fields[0]; | |||||||||||||||||||||||||||
| 203 | 0 | my $rel_key = $foreign_fields[0]; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 0 | my ($name_field) = grep { $_ !~ /^$rel_key$/ } @rel_fields; | |||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 0 | my $related_element = { | |||||||||||||||||||||||||||
| 208 | 'type' => 'Multi', | ||||||||||||||||||||||||||||
| 209 | 'nested_name' => $relation, | ||||||||||||||||||||||||||||
| 210 | 'exchanges_field' => $field_to_exchange, | ||||||||||||||||||||||||||||
| 211 | 'key' => $rel_key, | ||||||||||||||||||||||||||||
| 212 | 'elements' => [ | ||||||||||||||||||||||||||||
| 213 | { | ||||||||||||||||||||||||||||
| 214 | 'type' => 'Text', | ||||||||||||||||||||||||||||
| 215 | 'name' => $name_field, | ||||||||||||||||||||||||||||
| 216 | }, | ||||||||||||||||||||||||||||
| 217 | ], | ||||||||||||||||||||||||||||
| 218 | }; | ||||||||||||||||||||||||||||
| 219 | 0 | return $related_element; | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | ▶ | sub order_field { | ||||||||||||||||||||||||||
|
Subroutine
order_field: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 223 | 0 | my ($self, $schema, $source) = @_; | |||||||||||||||||||||||||||
| 224 | 0 | ▶ | return undef unless $source; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 0 | my @columns = $schema->source($source)->columns; | |||||||||||||||||||||||||||
| 227 | 0 | my @source_ids = grep {/name/} @columns; | |||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 0 | my @primary_columns = $schema->source($source)->primary_columns; | |||||||||||||||||||||||||||
| 230 | 0 | push @source_ids, @primary_columns; | |||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | #my $table_name = $schema->class($source)->table; | ||||||||||||||||||||||||||||
| 233 | 0 | my $table_name = lc $source; | |||||||||||||||||||||||||||
| 234 | 0 | push @source_ids, grep {/${table_name}_id/} @columns; | |||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 0 | ▶ | return $source_ids[0] if (scalar @source_ids); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 0 | ▶ | return $columns[0] if (scalar @columns); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 0 | ▶ | sub id_and_name { | ||||||||||||||||||||||||||
|
Subroutine
id_and_name: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 241 | 0 | my ($self, $schema, $source) = @_; | |||||||||||||||||||||||||||
| 242 | 0 | ▶ | return undef unless $source; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 0 | my @columns = $schema->source($source)->columns; | |||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 0 | my @source_ids; | |||||||||||||||||||||||||||
| 246 | 0 | my @primary_columns = $schema->source($source)->primary_columns; | |||||||||||||||||||||||||||
| 247 | 0 | push @source_ids, $primary_columns[0]; | |||||||||||||||||||||||||||
| 248 | 0 | push @source_ids, grep {/name/} @columns; | |||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | #push @source_ids, $primary_columns[1] unless (scalar @source_ids >= 2); | ||||||||||||||||||||||||||||
| 251 | 0 | ▶ | push @source_ids, $columns[1] unless (scalar @source_ids >= 2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 0 | return @source_ids; | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 257 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 258 | 0 | my $class_name = ref $self; | |||||||||||||||||||||||||||
| 259 | 0 | $class_name =~ s/^.*::(\w+)$/$1/; | |||||||||||||||||||||||||||
| 260 | 0 | return $class_name; | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub type { | ||||||||||||||||||||||||||
|
Subroutine
type: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 264 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 265 | 0 | ▶ | my $data_type = shift || 'text'; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 'text'
MC/DC0%0/1
shift() || 'text'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | my $data2elem = { | |||||||||||||||||||||||||||
| 268 | 'integer' => 'number', | ||||||||||||||||||||||||||||
| 269 | 'varchar' => 'text', | ||||||||||||||||||||||||||||
| 270 | 'tinyint' => 'checkbox', | ||||||||||||||||||||||||||||
| 271 | 'enum' => 'enum', | ||||||||||||||||||||||||||||
| 272 | }; | ||||||||||||||||||||||||||||
| 273 | 0 | ▶ | return $data2elem->{$data_type} ? $data2elem->{$data_type} : 'text'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 2 | 1; | |||||||||||||||||||||||||||