blib/lib/DBIO/PostgreSQL/Result.pm

filter: Statementstmt 100% 100 / 100 Branchbran 89.2% 25 / 28 Conditioncond 55.5% 5 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 100% 18 / 18 Podpod 100% 13 / 13 totaltotal 93.1% 162 / 174 CC 18 SCAR 9.4
CC
18
Cov
95%
pg_unique_options
4.1
register_column
4.0
pg_check_constraint
4.0
CRAP 2.6
« blib/lib/DBIO/PostgreSQL/Vector/Op.pm ↑ Summary blib/lib/DBIO/PostgreSQL/Diff/Dependents.pm »
1 package DBIO::PostgreSQL::Result;
2 # ABSTRACT: PostgreSQL-specific Result component for DBIO
3  
4 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 28 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 28 our $VERSION = '0.900007';
8  
9 28 ▶use base 'DBIO::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 28 ▶use DBIO::PostgreSQL::ResultSet ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 28 ▶use DBIO::PostgreSQL::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # karr k40: pgvector columns inflate/deflate by default. Loading the
15 # InflateColumn::Vector component here makes declaring a vector/halfvec/
16 # sparsevec column the whole opt-in — the same way this class already
17 # promotes resultset_class for those columns. Opt out per column with
18 # inflate_pgvector => 0.
19 28 __PACKAGE__->load_components('PostgreSQL::InflateColumn::Vector');
20  
21 # karr k65: tsvector columns inflate/deflate by default, same opt-in-by-
22 # declaration model. Unlike Vector this carries no resultset_class promotion
23 # (that is pgvector/nearest_neighbors-specific). Opt out per column with
24 # inflate_tsvector => 0.
25 28 __PACKAGE__->load_components('PostgreSQL::InflateColumn::TSVector');
26  
27 28 __PACKAGE__->mk_classdata('_pg_schema_name');
28 28 __PACKAGE__->mk_classdata('_pg_indexes' => {});
29 28 __PACKAGE__->mk_classdata('_pg_triggers' => {});
30 28 __PACKAGE__->mk_classdata('_pg_rls');
31 28 __PACKAGE__->mk_classdata('_pg_check_constraints' => {});
32 28 __PACKAGE__->mk_classdata('_pg_extra_ddl' => []);
33 28 __PACKAGE__->mk_classdata('_pg_fk_constraints_from_rels' => 1);
34 28 __PACKAGE__->mk_classdata('_pg_unique_options' => {});
35  
36  
37  
38 782 ▶sub pg_schema {
Subroutine pg_schema: called CC=2 SCAR=6.9
Pod documented
39 782 my ($class, $name) = @_;
40 782 ▶ if (defined $name) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) 15 767 782
41 15 $class->_pg_schema_name($name);
42 }
43 782 return $class->_pg_schema_name;
44 }
45  
46  
47 9 ▶sub pg_qualified_table {
Subroutine pg_qualified_table: called CC=2 SCAR=6.9
Pod documented
48 9 my ($class) = @_;
49 9 my $schema = $class->_pg_schema_name;
50 9 my $table = $class->table;
51 9 ▶ return DBIO::PostgreSQL::Util::quote_qualified(
Branch: 1 branch
BranchTrueFalseTotal
$schema ? : 7 2 9
52 ($schema ? $schema : ()), $table,
53 );
54 }
55  
56  
57 33 ▶sub pg_index {
Subroutine pg_index: called CC=2 SCAR=7.0
Pod documented
58 33 my ($class, $name, $def) = @_;
59 33 ▶ if ($def) {
Branch: 1 branch
BranchTrueFalseTotal
if ($def) 33 0 33
60 33 my $indexes = { %{ $class->_pg_indexes } };
61 33 $indexes->{$name} = $def;
62 33 $class->_pg_indexes($indexes);
63 }
64 33 return $class->_pg_indexes->{$name};
65 }
66  
67  
68 227 ▶sub pg_indexes {
Subroutine pg_indexes: called CC=1 SCAR=0.0
Pod documented
69 227 my ($class) = @_;
70 227 return { %{ $class->_pg_indexes } };
71 }
72  
73  
74 5 ▶sub pg_trigger {
Subroutine pg_trigger: called CC=2 SCAR=7.0
Pod documented
75 5 my ($class, $name, $def) = @_;
76 5 ▶ if ($def) {
Branch: 1 branch
BranchTrueFalseTotal
if ($def) 5 0 5
77 5 my $triggers = { %{ $class->_pg_triggers } };
78 5 $triggers->{$name} = $def;
79 5 $class->_pg_triggers($triggers);
80 }
81 5 return $class->_pg_triggers->{$name};
82 }
83  
84  
85 219 ▶sub pg_triggers {
Subroutine pg_triggers: called CC=1 SCAR=0.0
Pod documented
86 219 my ($class) = @_;
87 219 return { %{ $class->_pg_triggers } };
88 }
89  
90  
91 231 ▶sub pg_rls {
Subroutine pg_rls: called CC=2 SCAR=6.9
Pod documented
92 231 my ($class, $def) = @_;
93 231 ▶ if ($def) {
Branch: 1 branch
BranchTrueFalseTotal
if ($def) 6 225 231
94 6 $class->_pg_rls($def);
95 }
96 231 return $class->_pg_rls;
97 }
98  
99  
100 5 ▶sub pg_check_constraint {
Subroutine pg_check_constraint: called CC=4 SCAR=13.9
Pod documented
101 5 my ($class, $name, $def) = @_;
102 5 ▶ if (defined $def) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $def) 3 2 5
103 3 ▶ my $entry = ref $def eq 'HASH' ? { %$def } : { definition => $def };
Branch: 1 branch
BranchTrueFalseTotal
ref $def eq 'HASH' ? : 1 2 3
104 3 ▶ $entry->{constraint_name} //= $name;
Condition66%2/3
$entry->{"constraint_name"} //= $name
l!l&&r!l&&!r
120
MC/DC0%0/2
$entry->{"constraint_name"} //= $name
$entry->{"constraint_name"} $name
Truth table66%2/3
A //= B
A= $entry->{"constraint_name"}B= $name
ABresult
1X1
011
000
105 3 my $checks = { %{ $class->_pg_check_constraints } };
106 3 $checks->{$name} = $entry;
107 3 $class->_pg_check_constraints($checks);
108 }
109 5 return $class->_pg_check_constraints->{$name};
110 }
111  
112  
113 219 ▶sub pg_check_constraints {
Subroutine pg_check_constraints: called CC=1 SCAR=0.0
Pod documented
114 219 my ($class) = @_;
115 219 return { %{ $class->_pg_check_constraints } };
116 }
117  
118  
119 225 ▶sub pg_extra_ddl {
Subroutine pg_extra_ddl: called CC=3 SCAR=11.0
Pod documented
120 225 my ($class, @stmts) = @_;
121 225 ▶ if (@stmts) {
Branch: 1 branch
BranchTrueFalseTotal
if (@stmts) 5 220 225
122 5 ▶ my @flat = map { ref eq 'ARRAY' ? @$_ : $_ } @stmts;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 1 5 6
123 5 my $cur = [ @{ $class->_pg_extra_ddl }, @flat ];
124 5 $class->_pg_extra_ddl($cur);
125 }
126 225 return [ @{ $class->_pg_extra_ddl } ];
127 }
128  
129  
130 235 ▶sub pg_unique_options {
Subroutine pg_unique_options: called CC=4 SCAR=14.1
Pod documented
131 235 my ($class, $name, $options) = @_;
132 235 ▶ if (defined $name) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) 6 229 235
133 6 ▶ $class->throw_exception('pg_unique_options takes the name of a UNIQUE constraint and a hash of options')
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options and ref $options eq "HASH" 0 6 6
Condition33%1/3
defined $options and ref $options eq "HASH"
!ll&&!rl&&r
006
MC/DC0%0/2
defined $options and ref $options eq "HASH"
defined $options ref $options eq "HASH"
Truth table33%1/3
A and B
A= defined $optionsB= ref $options eq "HASH"
ABresult
0X0
100
111
134 unless defined $options && ref $options eq 'HASH';
135 6 $class->_pg_unique_options({ %{ $class->_pg_unique_options }, $name => { %$options } });
136 }
137 235 return { map { $_ => { %{ $class->_pg_unique_options->{$_} } } } keys %{ $class->_pg_unique_options } };
138 }
139  
140  
141 304 ▶sub pg_fk_constraints_from_rels {
Subroutine pg_fk_constraints_from_rels: called CC=2 SCAR=6.9
Pod documented
142 304 my ($class, $bool) = @_;
143 304 ▶ if (defined $bool) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $bool) 63 241 304
144 63 $class->_pg_fk_constraints_from_rels($bool);
145 }
146 304 return $class->_pg_fk_constraints_from_rels;
147 }
148  
149  
150 518 ▶sub register_column {
Subroutine register_column: called CC=4 SCAR=13.9
Pod documented
151 518 my ($class, $column, $info, @rest) = @_;
152 518 $class->next::method($column, $info, @rest);
153  
154 # Single pgvector-type detection site: reuse the shared helper from the
155 # InflateColumn::Vector component (loaded above), so promotion and inflation
156 # share one regex with identical whitespace tolerance (karr k61).
157 518 my ($type) = $class->_pgvector_type_info($info->{data_type});
158 518 ▶ return unless $type;
Branch: 1 branch
BranchTrueFalseTotal
unless $type 495 23 518
159  
160 23 my $rs_class = $class->resultset_class;
161 23 ▶ $class->resultset_class('DBIO::PostgreSQL::ResultSet')
Branch: 1 branch
BranchTrueFalseTotal
if $rs_class and not $rs_class->isa("DBIO::PostgreSQL::ResultSet") 13 10 23
Condition66%2/3
$rs_class and not $rs_class->isa("DBIO::PostgreSQL::ResultSet")
!ll&&!rl&&r
01013
MC/DC50%1/2
$rs_class and not $rs_class->isa("DBIO::PostgreSQL::ResultSet")
$rs_class not $rs_class->isa("DBIO::PostgreSQL::ResultSet")
Truth table66%2/3
A and not(B)
A= $rs_classB= not $rs_class->isa("DBIO::PostgreSQL::ResultSet")
ABresult
0X0
100
111
162 if $rs_class && !$rs_class->isa('DBIO::PostgreSQL::ResultSet');
163  
164 23 return;
165 }
166  
167  
168 28 1;
169  
170 __END__
« blib/lib/DBIO/PostgreSQL/Vector/Op.pm ↑ Summary blib/lib/DBIO/PostgreSQL/Diff/Dependents.pm »