Branch Coverage: lib/OpenAPI/Handler/Model.pm

# Branch Coverage

File: | lib/OpenAPI/Handler/Model.pm
Coverage: | 75.4%

line | % | coverage | branch
--- | --- | --- | ---
11 | 100 | T | F | if (not $type =~ /^ \s* ( text | integer | serial | real | double precision | date | (?:timestamp|time) (?: \s* \( \s* \d+ \s* \) )? (?: \s* with(?:out)? \s+ time \s+ zone)? | interval (?: \s* \( \s* \d+ \s* \) )? ) \s* $ /x)
32 | 50 | T | F | if (not $res)
64 | 100 | T | F | unless my $data = _HASH($$self{'_req_data'})
69 | 100 | T | F | if ($model eq '~')
73 | 100 | T | F | if ($name = delete $$data{'name'} and $name ne $model)
84 | 100 | T | F | if ($model eq '~')
87 | 50 | T | F | if (not $self->has_model($model))
106 | 100 | T | F | if ($col eq '~') { }
108 | 50 | T | F | if (not $list or not ref $list)
114 | 50 | T | F | if (not $res or not @$res)
131 | 50 | T | F | if ($num >= $COLUMN_LIMIT)
135 | 50 | T | F | unless $data = _HASH $data
136 | 50 | T | F | if ($col eq 'id')
139 | 100 | T | F | if ($col eq '~')
146 | 100 | T | F | if (defined $fst)
151 | 50 | T | F | unless my $label = $$data{'label'}
159 | 100 | T | F | if (defined $default)
170 | 100 | T | F | if $alias and $alias ne $col
181 | 100 | T | F | unless my $data = _HASH($$self{'_req_data'})
186 | 50 | T | F | if (lc $col eq 'id')
193 | 100 | T | F | if ($new_col) { }
194 | 50 | T | F | unless _IDENT($new_col)
205 | 100 | T | F | if ($type)
213 | 100 | T | F | if (defined $label)
214 | 50 | T | F | unless _STRING $label
220 | 100 | T | F | if (defined $default)
234 | 50 | T | F | $res ? :
244 | 100 | T | F | if (lc $col eq 'id')
249 | 100 | T | F | if ($col eq '~') { }
260 | 50 | T | F | $res > -1 ? :
278 | 100 | T | F | if ($column ne '~' and $value ne '~')
281 | 100 | T | F | if ($column ne '~' and $value eq '~')
284 | 100 | T | F | if ($column eq '~' and $value eq '~')
287 | 50 | T | F | if ($column eq '~') { }
299 | 100 | T | F | if ($value eq '~')
326 | 50 | T | F | if ($nmodels >= $MODEL_LIMIT)
330 | 50 | T | F | unless my $model = delete $$data{'name'}
334 | 100 | T | F | unless my $description = delete $$data{'description'}
336 | 100 | T | F | unless _STRING $description
340 | 50 | T | F | if (not ref $data)
345 | 100 | T | F | if (_HASH $columns)
346 | 100 | T | F | if ($columns and not _ARRAY0 $columns) { }
| 100 | T | F | elsif (not $columns) { }
| 100 | T | F | elsif (not @$columns) { }
354 | 50 | T | F | if (@$columns > $COLUMN_LIMIT)
358 | 100 | T | F | if (%$data)
364 | 100 | T | F | if ($self->has_model($model))
379 | 100 | T | F | unless _HASH $col
380 | 50 | T | F | unless my $name = delete $$col{'name'}
382 | 100 | T | F | unless _STRING $name
383 | 100 | T | F | unless _IDENT($name)
384 | 100 | T | F | if (length $name >= 32)
389 | 100 | T | F | if (lc $name eq 'id')
395 | 100 | T | F | unless my $label = $$col{'label'}
403 | 100 | T | F | if (defined $default)
421 | 50 | T | F | if ($@)
425 | 100 | T | F | $found_id ? :
432 | 50 | T | F | if (not $expr =~ /^ \s* ( now \s* \( \s* \) (?: \s+ at \s+ time \s+ zone \s+ '[^']+' )? ) \s* $ /x)
445 | 100 | T | F | if (_STRING($default || $default eq '0')) { }
| 50 | T | F | elsif (_ARRAY $default) { }
458 | 50 | T | F | unless _IDENT($model)
475 | 100 | T | F | if (@$rbits >= 2)
477 | 100 | T | F | unless _IDENT($model) or $model eq '~'
478 | 100 | T | F | if (length $model >= 32)
482 | 100 | T | F | if (@$rbits >= 3)
485 | 100 | T | F | unless _IDENT($col) or $col eq '~'
488 | 100 | T | F | if ($meth eq 'POST') { }
490 | 100 | T | F | if (@$rbits >= 3 and $model ne '~')
491 | 100 | T | F | if (not $self->has_model($model))
498 | 100 | T | F | if ($model and $model ne '~')
499 | 100 | T | F | if (not $self->has_model($model))
504 | 100 | T | F | if ($col and $col ne '~')
505 | 100 | T | F | if ($model ne '~' and not $self->has_model_col($model, $col))
542 | 50 | T | F | if (not $self->has_model($model))
556 | 50 | T | F | if (not $list or not ref $list)
564 | 50 | T | F | if (not $self->has_model($model))
573 | 50 | T | F | if (not $list or not ref $list)
579 | 50 | T | F | unless _IDENT($model)
580 | 100 | T | F | unless _IDENT($col)
583 | 100 | T | F | if $col eq 'id'
607 | 50 | T | F | if (not ref $data)
612 | 50 | T | F | if ($self->row_count($table) >= $RECORD_LIMIT)
622 | 50 | T | F | if ($user eq $special_account)
631 | 100 | T | F | if (ref $data eq 'HASH') { }
| 50 | T | F | elsif (ref $data eq 'ARRAY') { }
637 | 50 | T | F | $num ? :
641 | 50 | T | F | if (@$data > $INSERT_LIMIT)
645 | 50 | T | F | unless _HASH $row_data
651 | 50 | T | F | $rows_affected ? :
663 | 50 | T | F | unless _IDENT($col)
670 | 100 | T | F | if (not $found)
681 | 100 | T | F | unless defined $order_by
682 | 100 | T | F | if $order_by eq ''
684 | 100 | T | F | if (not @sub_order_by and $order_by)
690 | 100 | T | F | unless $self->has_model_col($model, $col)
692 | 100 | T | F | if $dir
693 | 100 | T | F | if $dir and $dir ne 'asc' and $dir ne 'desc'
702 | 100 | T | F | if ($offset)
710 | 50 | T | F | if (defined $limit)
720 | 100 | T | F | if (lc $user_col ne 'id' and $user_col ne '~')
723 | 100 | T | F | if ($col eq $user_col)
725 | 50 | T | F | if (not $found)
729 | 100 | T | F | if (defined $val and $val ne '~') { }
732 | 100 | T | F | if ($op eq 'like')
736 | 100 | T | F | if ($user_col eq '~') { }
753 | 50 | T | F | if (not $res and not ref $res)
761 | 50 | T | F | if (not $self->has_model($model))
773 | 50 | T | F | if (not $list or not ref $list)
779 | 50 | T | F | if (not $self->has_model($model))
789 | 50 | T | F | if (not $self->has_model($model))
794 | 50 | T | F | if (lc $user_col ne 'id')
797 | 0 | T | F | if ($col eq $user_col)
799 | 0 | T | F | if (not $found)
803 | 50 | T | F | if (defined $val) { }
817 | 50 | T | F | if ($user_col ne 'id' and $user_col ne '~')
820 | 0 | T | F | if ($col eq $user_col)
823 | 0 | T | F | if (not $found)
825 | 50 | T | F | if (not ref $data or ref $data ne 'HASH')
831 | 100 | T | F | if (lc $col eq 'id')
837 | 100 | T | F | if (defined $val and $val ne '~')
842 | 100 | T | F | $retval ? :
847 | 50 | T | F | unless my $model = _IDENT($_[1])
848 | 50 | T | F | unless my $data = _HASH($_[2])
850 | 50 | T | F | if (not $self->has_model($model))
856 | 100 | T | F | if ($new_model = delete $$data{'name'})
857 | 50 | T | F | unless _IDENT($new_model)
859 | 50 | T | F | if ($self->has_model($new_model))
869 | 50 | T | F | if (my $desc = delete $$data{'description'})
870 | 50 | T | F | unless _STRING $desc
873 | 50 | T | F | if (%$data)