Helper/Schema/Verifier/ColumnInfo.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 100% 42 / 42 CC 4 SCAR 7.4
CC
4
Cov
100%
__ANON__
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.1
« Helper/Row/ProxyResultSetMethod.pm ↑ Summary Helper/ResultSet/Random.pm »
1 package DBIx::Class::Helper::Schema::Verifier::ColumnInfo;
2 1 $DBIx::Class::Helper::Schema::Verifier::ColumnInfo::VERSION = '2.037000';
3 # ABSTRACT: Verify that Results only use approved column_info keys
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use MRO::Compat;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use base 'DBIx::Class::Helper::Schema::Verifier';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 my @allowed_keys = (
14 # defaults from ::ResultSource
15 qw(
16 accessor
17 auto_nextval
18 data_type
19 default_value
20 extra
21 is_auto_increment
22 is_foreign_key
23 is_nullable
24 is_numeric
25 retrieve_on_insert
26 sequence
27 size
28 ),
29 # ::InflateColumn::DateTime
30 qw(
31 floating_tz_ok
32 inflate_datetime
33 locale
34 timezone
35 ),
36 # ::InflateColumn::File and ::InflateColumn::FS
37 qw(
38 file_column_path
39 fs_column_path
40 fs_new_on_update
41 is_file_column
42 is_fs_column
43 ),
44 # ::Helpers
45 qw(
46 is_serializable
47 keep_storage_value
48 remove_column
49 ) );
50  
51 3 ▶sub allowed_column_keys { @allowed_keys }
Subroutine allowed_column_keys: called CC=1 SCAR=0.0
Pod documented
52  
53 3 ▶sub result_verifiers {
Subroutine result_verifiers: called CC=1 SCAR=0.0
Pod documented
54 3 my $self = shift;
55 3 my %allowed = map { $_ => 1 } $self->allowed_column_keys;
56  
57 (
58 3 ▶ sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
59 3 my ($s, $result, $set) = @_;
60 3 my $column_info = $result->columns_info;
61 3 for my $col_name (keys %$column_info) {
62 3 for my $key (keys %{ $column_info->{$col_name} }) {
63 14 ▶ if (!$allowed{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($allowed{$key}) 1 13 14
64 1 die sprintf join(' ', qw(Forbidden column config <%s> used in
65 column <%s> in result <%s>. You can explicitly allow it by
66 adding it to your schema's allowed_column_keys method.)),
67 $key, $col_name, $result;
68 }
69 }
70 }
71 },
72 3 $self->next::method,
73 )
74 }
75  
76 1 1;
77  
78 __END__
« Helper/Row/ProxyResultSetMethod.pm ↑ Summary Helper/ResultSet/Random.pm »