Sybase/Introspect/Tables.pm

filter: Statementstmt 100% 16 / 16 Branchbran 100% 2 / 2 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 85.7% 24 / 28 CC 5 SCAR 13.6
CC
5
Cov
91%
fetch
5.1
BEGIN
1.0
BEGIN
1.0
CRAP 3.9
« Sybase/Introspect.pm ↑ Summary Sybase/Diff/View.pm »
1 package DBIO::Sybase::Introspect::Tables;
2 # ABSTRACT: Introspect Sybase ASE tables and views
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  
10  
11 14 ▶sub fetch {
Subroutine fetch: called CC=5 SCAR=16.2
Pod documented
12 14 my ($class, $dbh, $schema) = @_;
13 14 ▶ $schema //= 'dbo';
Condition50%1/2
$schema //= "dbo"
l!l
140
MC/DC0%0/1
$schema //= "dbo"
$schema
Truth table50%1/2
A
A= $schema
Aresult
11
00
14  
15 14 my $rows = $dbh->selectall_arrayref(q{
16 SELECT o.name AS table_name, o.type AS object_type
17 FROM sysobjects o
18 JOIN sysusers u ON u.uid = o.uid
19 WHERE o.type IN ('U', 'V')
20 AND u.name = ?
21 AND o.name <> 'sysquerymetrics'
22 ORDER BY o.name
23 }, { Slice => {} }, $schema);
24  
25 14 my %tables;
26 14 for my $row (@$rows) {
27 # sysobjects.type is char(2): 'U ' / 'V '.
28 42 ▶ (my $type = $row->{object_type} // '') =~ s/\s+//g;
Condition50%1/2
$row->{"object_type"} // ""
l!l
420
MC/DC0%0/1
$row->{"object_type"} // ""
$row->{"object_type"}
Truth table50%1/2
A
A= $row->{"object_type"}
Aresult
11
00
29 $tables{ $row->{table_name} } = {
30 table_name => $row->{table_name},
31 42 ▶ kind => $type eq 'V' ? 'view' : 'table',
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'V' ? : 14 28 42
32 schema => $schema,
33 };
34 }
35  
36 14 return \%tables;
37 }
38  
39 28 1;
40  
41 __END__
« Sybase/Introspect.pm ↑ Summary Sybase/Diff/View.pm »