Async/ORM/Schema.pm

filter: Statementstmt 36.1% 13 / 36 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 23.0% 3 / 13 Podpod 0.0% 0 / 10 totaltotal 22.2% 16 / 72 CC 6 SCAR 15.8
CC
6
Cov
28%
type_by_name
12.0
tables
6.0
types
6.0
CRAP 4.8
« Async/Query.pm ↑ Summary Async/ORM/Table.pm »
1 package Database::Async::ORM::Schema;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '0.019'; # VERSION
7  
8 2 ▶use Database::Async::ORM::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
11 0 my ($class) = shift;
12 0 bless { @_ }, $class
13 }
14  
15 0 ▶sub name { shift->{name} }
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
16 0 ▶sub defined_in { shift->{defined_in} }
Subroutine defined_in: not called CC=1 SCAR=6.9
Pod undocumented
17 0 ▶sub description { shift->{description} }
Subroutine description: not called CC=1 SCAR=6.9
Pod undocumented
18 0 ▶sub tables { (shift->{tables} // [])->@* }
Subroutine tables: not called CC=2 SCAR=17.9
Pod undocumented
Condition0%0/2
+(shift())->{"tables"} // []
l!l
00
MC/DC0%0/1
+(shift())->{"tables"} // []
+(shift())->{"tables"}
Truth table0%0/2
A
A= +(shift())->{"tables"}
Aresult
11
00
19 0 ▶sub types { (shift->{types} // [])->@* }
Subroutine types: not called CC=2 SCAR=17.9
Pod undocumented
Condition0%0/2
+(shift())->{"types"} // []
l!l
00
MC/DC0%0/1
+(shift())->{"types"} // []
+(shift())->{"types"}
Truth table0%0/2
A
A= +(shift())->{"types"}
Aresult
11
00
20  
21 0 ▶sub table_by_name {
Subroutine table_by_name: not called CC=2 SCAR=17.9
Pod undocumented
22 0 my ($self, $name) = @_;
23 0 ▶ (grep { $_->name eq $name } (shift->{tables} // [])->@*)[0]
Condition0%0/2
+(shift())->{"tables"} // []
l!l
00
MC/DC0%0/1
+(shift())->{"tables"} // []
+(shift())->{"tables"}
Truth table0%0/2
A
A= +(shift())->{"tables"}
Aresult
11
00
24 }
25  
26 0 ▶sub add_table {
Subroutine add_table: not called CC=1 SCAR=6.9
Pod undocumented
27 0 my ($self, $table) = @_;
28 0 push @{$self->{tables}}, $table;
29 0 $self;
30 }
31  
32 0 ▶sub add_type {
Subroutine add_type: not called CC=1 SCAR=6.9
Pod undocumented
33 0 my ($self, $type) = @_;
34 0 push @{$self->{types}}, $type;
35 0 $self;
36 }
37  
38 my %predefined_types = map {
39 2 $_ => Database::Async::ORM::Type->new(
40 defined_in => 'postgres',
41 name => $_,
42 schema => undef,
43 type => $_,
44 description => $_,
45 is_builtin => 1,
46 )
47 } qw(
48 serial
49 bigserial
50 bigint
51 int
52 boolean
53 bool
54 bytea
55 char
56 name
57 int8
58 int2
59 int2vector
60 int4
61 regproc
62 text
63 oid
64 tid
65 xid
66 cid
67 oidvector
68 pg_type
69 pg_attribute
70 pg_proc
71 pg_class
72 json
73 xml
74 _xml
75 _json
76 pg_node_tree
77 pg_ndistinct
78 pg_dependencies
79 pg_ddl_command
80 smgr
81 point
82 lseg
83 path
84 box
85 polygon
86 line
87 _line
88 float4
89 float8
90 double
91 abstime
92 reltime
93 tinterval
94 unknown
95 circle
96 _circle
97 money
98 _money
99 macaddr
100 inet
101 cidr
102 macaddr8
103 _bool
104 _bytea
105 _char
106 _name
107 _int2
108 _int2vector
109 _int4
110 _regproc
111 _text
112 _oid
113 _tid
114 _xid
115 _cid
116 _oidvector
117 _bpchar
118 _varchar
119 _int8
120 _point
121 _lseg
122 _path
123 _box
124 _float4
125 _float8
126 _abstime
127 _reltime
128 _tinterval
129 _polygon
130 aclitem
131 _aclitem
132 _macaddr
133 _macaddr8
134 _inet
135 _cidr
136 _cstring
137 bpchar
138 varchar
139 date
140 time
141 timestamp
142 _timestamp
143 _date
144 _time
145 timestamptz
146 _timestamptz
147 interval
148 _interval
149 _numeric
150 timetz
151 _timetz
152 bit
153 _bit
154 varbit
155 _varbit
156 numeric
157 refcursor
158 _refcursor
159 regprocedure
160 regoper
161 regoperator
162 regclass
163 regtype
164 regrole
165 regnamespace
166 _regprocedure
167 _regoper
168 _regoperator
169 _regclass
170 _regtype
171 _regrole
172 _regnamespace
173 uuid
174 _uuid
175 pg_lsn
176 _pg_lsn
177 tsvector
178 gtsvector
179 tsquery
180 regconfig
181 regdictionary
182 _tsvector
183 _gtsvector
184 _tsquery
185 _regconfig
186 _regdictionary
187 jsonb
188 _jsonb
189 txid_snapshot
190 _txid_snapshot
191 int4range
192 _int4range
193 numrange
194 _numrange
195 tsrange
196 _tsrange
197 tstzrange
198 _tstzrange
199 daterange
200 _daterange
201 int8range
202 _int8range
203 record
204 _record
205 cstring
206 any
207 anyarray
208 void
209 trigger
210 event_trigger
211 language_handler
212 internal
213 opaque
214 anyelement
215 anynonarray
216 anyenum
217 fdw_handler
218 index_am_handler
219 tsm_handler
220 anyrange
221 pg_attrdef
222 pg_constraint
223 pg_inherits
224 pg_index
225 pg_operator
226 pg_opfamily
227 pg_opclass
228 pg_am
229 pg_amop
230 pg_amproc
231 pg_language
232 pg_largeobject_metadata
233 pg_largeobject
234 pg_aggregate
235 pg_statistic_ext
236 pg_statistic
237 pg_rewrite
238 pg_trigger
239 pg_event_trigger
240 pg_description
241 pg_cast
242 pg_enum
243 pg_namespace
244 pg_conversion
245 pg_depend
246 pg_database
247 pg_db_role_setting
248 pg_tablespace
249 pg_pltemplate
250 pg_authid
251 pg_auth_members
252 pg_shdepend
253 pg_shdescription
254 pg_ts_config
255 pg_ts_config_map
256 pg_ts_dict
257 pg_ts_parser
258 pg_ts_template
259 pg_extension
260 pg_foreign_data_wrapper
261 pg_foreign_server
262 pg_user_mapping
263 pg_foreign_table
264 pg_policy
265 pg_replication_origin
266 pg_default_acl
267 pg_init_privs
268 pg_seclabel
269 pg_shseclabel
270 pg_collation
271 pg_partitioned_table
272 pg_range
273 pg_transform
274 pg_sequence
275 pg_publication
276 pg_publication_rel
277 pg_subscription
278 pg_subscription_rel
279 pg_roles
280 pg_shadow
281 pg_group
282 pg_user
283 pg_policies
284 pg_rules
285 pg_views
286 pg_tables
287 pg_matviews
288 pg_indexes
289 pg_sequences
290 pg_stats
291 pg_publication_tables
292 pg_locks
293 pg_cursors
294 pg_available_extensions
295 pg_available_extension_versions
296 pg_prepared_xacts
297 pg_prepared_statements
298 pg_seclabels
299 pg_settings
300 pg_file_settings
301 pg_hba_file_rules
302 pg_timezone_abbrevs
303 pg_timezone_names
304 pg_config
305 pg_stat_all_tables
306 pg_stat_xact_all_tables
307 pg_stat_sys_tables
308 pg_stat_xact_sys_tables
309 pg_stat_user_tables
310 pg_stat_xact_user_tables
311 pg_statio_all_tables
312 pg_statio_sys_tables
313 pg_statio_user_tables
314 pg_stat_all_indexes
315 pg_stat_sys_indexes
316 pg_stat_user_indexes
317 pg_statio_all_indexes
318 pg_statio_sys_indexes
319 pg_statio_user_indexes
320 pg_statio_all_sequences
321 pg_statio_sys_sequences
322 pg_statio_user_sequences
323 pg_stat_activity
324 pg_stat_replication
325 pg_stat_wal_receiver
326 pg_stat_subscription
327 pg_stat_ssl
328 pg_replication_slots
329 pg_stat_database
330 pg_stat_database_conflicts
331 pg_stat_user_functions
332 pg_stat_xact_user_functions
333 pg_stat_archiver
334 pg_stat_bgwriter
335 pg_stat_progress_vacuum
336 pg_user_mappings
337 pg_replication_origin_status
338 hstore
339 integer
340 );
341  
342 0 ▶sub type_by_name {
Subroutine type_by_name: not called CC=3 SCAR=24.8
Pod undocumented
343 0 my ($self, $name) = @_;
344 0 ▶ return $predefined_types{$name} if $predefined_types{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $predefined_types{$name} 0 0 0
345 my ($type) = grep {
346 0 $_->{name} eq $name
347 0 ▶ } $self->{types}->@* or die 'cannot find type ' . $name;
Branch: 1 branch
BranchTrueFalseTotal
my($type) = grep({$_->{"name"} eq $name;} @{$$self{"types"}}) or die 'cannot find type ' . $name 0 0 0
348 0 return $type;
349 }
350  
351 2 1;
352  
« Async/Query.pm ↑ Summary Async/ORM/Table.pm »