| 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"
MC/DC0%0/1
$schema //= "dbo"
$schema
Truth table50%1/2
A
A= $schema
| |||||||||||||
| 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"} // ""
MC/DC0%0/1
$row->{"object_type"} // ""
$row->{"object_type"}
Truth table50%1/2
A
A= $row->{"object_type"}
| |||||||||||||
| 29 | $tables{ $row->{table_name} } = { | ||||||||||||
| 30 | table_name => $row->{table_name}, | ||||||||||||
| 31 | 42 | ▶ | kind => $type eq 'V' ? 'view' : 'table', | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 32 | schema => $schema, | ||||||||||||
| 33 | }; | ||||||||||||
| 34 | } | ||||||||||||
| 35 | |||||||||||||
| 36 | 14 | return \%tables; | |||||||||||
| 37 | } | ||||||||||||
| 38 | |||||||||||||
| 39 | 28 | 1; | |||||||||||
| 40 | |||||||||||||
| 41 | __END__ | ||||||||||||