| 1 | package DBIx::Class::Helper::ResultSet::AutoRemoveColumns; | ||||||||||||||||||||||||||||
| 2 | 56 | $DBIx::Class::Helper::ResultSet::AutoRemoveColumns::VERSION = '2.037000'; | |||||||||||||||||||||||||||
| 3 | # ABSTRACT: Automatically remove columns from a ResultSet | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 56 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 56 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 56 | ▶ | use parent 'DBIx::Class::Helper::ResultSet::RemoveColumns', 'DBIx::Class::ResultSet'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 56 | __PACKAGE__->mk_group_accessors(inherited => '_fetchable_columns'); | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 56 | my %dont_fetch = ( | |||||||||||||||||||||||||||
| 13 | text => 1, | ||||||||||||||||||||||||||||
| 14 | ntext => 1, | ||||||||||||||||||||||||||||
| 15 | blob => 1, | ||||||||||||||||||||||||||||
| 16 | clob => 1, | ||||||||||||||||||||||||||||
| 17 | bytea => 1, | ||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 228 | ▶ | sub _should_column_fetch { | ||||||||||||||||||||||||||
|
Subroutine
_should_column_fetch: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 21 | 228 | my ( $self, $column ) = @_; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 228 | my $info = $self->result_source->column_info($column); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 228 | ▶ | if (!defined $info->{remove_column}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 132 | ▶ | if (defined $info->{data_type} && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $info->{"data_type"} and $dont_fetch{lc $info->{"data_type"}}
MC/DC50%1/2
defined $info->{"data_type"} and $dont_fetch{lc $info->{"data_type"}}
defined $info->{"data_type"}
$dont_fetch{lc $info->{"data_type"}}
Truth table66%2/3
A and B
A= defined $info->{"data_type"}B= $dont_fetch{lc $info->{"data_type"}}
| |||||||||||||||||||||||||||||
| 27 | $dont_fetch{lc $info->{data_type}} | ||||||||||||||||||||||||||||
| 28 | ) { | ||||||||||||||||||||||||||||
| 29 | 88 | $info->{remove_column} = 1; | |||||||||||||||||||||||||||
| 30 | } else { | ||||||||||||||||||||||||||||
| 31 | 44 | $info->{remove_column} = 0; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 228 | return $info->{remove_column}; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 111 | ▶ | sub fetchable_columns { | ||||||||||||||||||||||||||
|
Subroutine
fetchable_columns: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | 111 | my $self = shift; | |||||||||||||||||||||||||||
| 40 | 111 | ▶ | if (!$self->_fetchable_columns) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 57 | $self->_fetchable_columns([ | |||||||||||||||||||||||||||
| 42 | grep $self->_should_column_fetch($_), | ||||||||||||||||||||||||||||
| 43 | $self->result_source->columns | ||||||||||||||||||||||||||||
| 44 | ]); | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 111 | return $self->_fetchable_columns; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 115 | ▶ | sub _resolved_attrs { | ||||||||||||||||||||||||||
|
Subroutine
_resolved_attrs: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 50 | local $_[0]->{attrs}{remove_columns} = | ||||||||||||||||||||||||||||
| 51 | 115 | ▶ | $_[0]->{attrs}{remove_columns} || $_[0]->fetchable_columns; | ||||||||||||||||||||||||||
|
Condition66%2/3
$_[0]{'attrs'}{'remove_columns'} || $_[0]->fetchable_columns
MC/DC0%0/2
$_[0]{'attrs'}{'remove_columns'} || $_[0]->fetchable_columns
$_[0]{'attrs'}{'remove_columns'}
$_[0]->fetchable_columns
Truth table66%2/3
A || B
A= $_[0]{'attrs'}{'remove_columns'}B= $_[0]->fetchable_columns
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 115 | return $_[0]->next::method; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 56 | 1; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||||||||||