blib/lib/DBIO/DuckDB/Introspect/Tables.pm

filter: Statementstmt 33.3% 8 / 24 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 26.1% 11 / 42 CC 7 SCAR 37.8
CC
7
Cov
22%
fetch
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 43.8
« blib/lib/DBIO/DuckDB/Diff/Table.pm ↑ Summary blib/lib/DBIO/DuckDB/Storage.pm »
1 package DBIO::DuckDB::Introspect::Tables;
2 # ABSTRACT: Introspect DuckDB tables and views
3  
4 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 our $VERSION = '0.900007';
8  
9  
10  
11 0 ▶sub fetch {
Subroutine fetch: not called CC=7 SCAR=40.3
Pod documented
12 0 my ($class, $dbh, $schema, $catalog) = @_;
13 0 ▶ $schema //= 'main';
Condition0%0/2
$schema //= "main"
l!l
00
MC/DC0%0/1
$schema //= "main"
$schema
Truth table0%0/2
A
A= $schema
Aresult
11
00
14  
15 0 my $sql = q{
16 SELECT t.table_name, t.table_type, v.view_definition
17 FROM information_schema.tables t
18 LEFT JOIN information_schema.views v
19 ON v.table_catalog = t.table_catalog
20 AND v.table_schema = t.table_schema
21 AND v.table_name = t.table_name
22 WHERE t.table_schema = ?
23 AND t.table_name NOT LIKE 'sqlite_%'
24 };
25 0 my @bind = ($schema);
26  
27 0 ▶ if (defined $catalog) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $catalog) 0 0 0
28 0 $sql .= q{ AND t.table_catalog = ?};
29 0 push @bind, $catalog;
30 }
31  
32 0 $sql .= q{ ORDER BY t.table_name};
33  
34 0 my $sth = $dbh->prepare($sql);
35 0 $sth->execute(@bind);
36  
37 0 my %tables;
38 0 ▶ while (my $row = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 0 0 0
39 0 ▶ my $type = lc($row->{table_type} // '');
Condition0%0/2
$row->{"table_type"} // ""
l!l
00
MC/DC0%0/1
$row->{"table_type"} // ""
$row->{"table_type"}
Truth table0%0/2
A
A= $row->{"table_type"}
Aresult
11
00
40 0 ▶ my $kind = $type =~ /view/ ? 'view' : 'table';
Branch: 1 branch
BranchTrueFalseTotal
$type =~ /view/ ? : 0 0 0
41 $tables{ $row->{table_name} } = {
42 table_name => $row->{table_name},
43 kind => $kind,
44 schema => $schema,
45 0 ▶ ( $kind eq 'view' ? ( view_definition => $row->{view_definition} ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'view' ? : 0 0 0
46 };
47 }
48  
49 0 return \%tables;
50 }
51  
52 10 1;
53  
54 __END__
« blib/lib/DBIO/DuckDB/Diff/Table.pm ↑ Summary blib/lib/DBIO/DuckDB/Storage.pm »