MSSQL/Introspect/Tables.pm

filter: Statementstmt 41.1% 7 / 17 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 32.2% 10 / 31 CC 5 SCAR 30.8
CC
5
Cov
28%
fetch
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 21.7
« MSSQL/Adapter.pm ↑ Summary MSSQL/Deploy.pm »
1 package DBIO::MSSQL::Introspect::Tables;
2 # ABSTRACT: Introspect MSSQL tables and views
3  
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8  
9 0 ▶sub fetch {
Subroutine fetch: not called CC=5 SCAR=34.0
Pod documented
10 0 my ($class, $dbh, $schema) = @_;
11 0 ▶ $schema //= 'dbo';
Condition0%0/2
$schema //= "dbo"
l!l
00
MC/DC0%0/1
$schema //= "dbo"
$schema
Truth table0%0/2
A
A= $schema
Aresult
11
00
12  
13 0 my $sth = $dbh->prepare(q{
14 SELECT table_name, table_type
15 FROM INFORMATION_SCHEMA.TABLES
16 WHERE table_schema = ?
17 ORDER BY table_name
18 });
19 0 $sth->execute($schema);
20  
21 0 my %tables;
22 0 ▶ while (my $row = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 0 0 0
23 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
24 0 ▶ my $kind = $type =~ /view/ ? 'view' : 'table';
Branch: 1 branch
BranchTrueFalseTotal
$type =~ /view/ ? : 0 0 0
25 $tables{ $row->{table_name} } = {
26 table_name => $row->{table_name},
27 0 kind => $kind,
28 schema => $schema,
29 };
30 }
31  
32 0 return \%tables;
33 }
34  
35 2 1;
36  
37 __END__
38  
39 =pod
40  
41 =encoding UTF-8
42  
43 =head1 NAME
44  
45 DBIO::MSSQL::Introspect::Tables - Introspect MSSQL tables and views
46  
47 =head1 VERSION
48  
49 version 0.900001
50  
51 =head1 DESCRIPTION
52  
53 Fetches MSSQL table and view metadata via C<INFORMATION_SCHEMA.TABLES>.
54 Skips system tables.
55  
56 =head1 METHODS
57  
58 =head2 fetch
59  
60 my $tables = DBIO::MSSQL::Introspect::Tables->fetch($dbh, $schema);
61  
62 Returns a hashref keyed by table name. Each value has: C<table_name>,
63 C<kind> (C<table> or C<view>), C<schema>.
64  
65 =head1 AUTHOR
66  
67 DBIO & DBIx::Class Authors
68  
69 =head1 COPYRIGHT AND LICENSE
70  
71 Copyright (C) 2026 DBIO Authors
72 Portions Copyright (C) 2005-2025 DBIx::Class Authors
73 Based on DBIx::Class, heavily modified.
74  
75 This is free software; you can redistribute it and/or modify it under
76 the same terms as the Perl 5 programming language system itself.
77  
78 =cut
« MSSQL/Adapter.pm ↑ Summary MSSQL/Deploy.pm »