Firebird/Introspect/Tables.pm

filter: Statementstmt 30.7% 8 / 26 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 27.5% 11 / 40 CC 6 SCAR 34.6
CC
6
Cov
22%
fetch
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 31.8
« Firebird/Introspect/Columns.pm ↑ Summary Firebird/Storage/Common.pm »
1 package DBIO::Firebird::Introspect::Tables;
2 # ABSTRACT: Introspect Firebird tables and views via rdb$relations
3  
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 our $VERSION = '0.900007';
8  
9  
10  
11 0 ▶sub fetch {
Subroutine fetch: not called CC=6 SCAR=37.4
Pod documented
12 0 my ($class, $dbh) = @_;
13  
14 0 my $sth = $dbh->prepare(q{
15 SELECT rdb$relation_name, rdb$view_source
16 FROM rdb$relations
17 WHERE rdb$system_flag = 0
18 AND rdb$relation_type IN (0, 1)
19 ORDER BY rdb$relation_name
20 });
21 0 $sth->execute;
22  
23 0 my %tables;
24 0 ▶ while (my $row = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 0 0 0
25 0 my $name = $row->{'rdb$relation_name'};
26 0 $name =~ s/\s+$//;
27 0 ▶ my $kind = defined $row->{'rdb$view_source'} ? 'view' : 'table';
Branch: 1 branch
BranchTrueFalseTotal
defined $row->{'rdb$view_source'} ? : 0 0 0
28 0 ▶ $tables{$name} = {
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'view' ? : 0 0 0
29 table_name => $name,
30 kind => $kind,
31 ( $kind eq 'view' ? ( view_source => "$row->{'rdb$view_source'}" ) : () ),
32 };
33 }
34  
35 0 my $pk = $dbh->prepare(q{
36 SELECT rdb$relation_name, rdb$constraint_name
37 FROM rdb$relation_constraints
38 WHERE rdb$constraint_type = 'PRIMARY KEY'
39 });
40 0 $pk->execute;
41 0 ▶ while (my $row = $pk->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $pk->fetchrow_hashref) 0 0 0
42 0 my ($table, $name) = map { my $v = $row->{$_}; $v =~ s/\s+$//; $v }
43 'rdb$relation_name', 'rdb$constraint_name';
44 0 ▶ $tables{$table}{primary_key_name} = $name if exists $tables{$table};
Branch: 1 branch
BranchTrueFalseTotal
if exists $tables{$table} 0 0 0
45 }
46  
47 0 return \%tables;
48 }
49  
50 6 1;
51  
52 __END__
« Firebird/Introspect/Columns.pm ↑ Summary Firebird/Storage/Common.pm »