k_Pg.pm

filter: Statementstmt 55.0% 22 / 40 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 75.0% 6 / 8 Podpod n/a totaltotal 45.1% 28 / 62 CC 6 SCAR 30.0
CC
6
Cov
43%
_tables
42.0
_db_class
2.0
BEGIN
1.0
CRAP 20.0
« Kinship.pm ↑ Summary
1 package Class::DBI::Loader::Pg;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use base 'Class::DBI::Loader::Generic';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 require Class::DBI::Pg;
11 2 require Class::DBI::Loader::Generic;
12  
13 2 $VERSION = '0.30';
14  
15 =head1 NAME
16  
17 Class::DBI::Loader::Pg - Class::DBI::Loader Postgres Implementation.
18  
19 =head1 SYNOPSIS
20  
21 use Class::DBI::Loader;
22  
23 # $loader is a Class::DBI::Loader::Pg
24 my $loader = Class::DBI::Loader->new(
25 dsn => "dbi:Pg:dbname=dbname",
26 user => "postgres",
27 password => "",
28 namespace => "Data",
29 );
30 my $class = $loader->find_class('film'); # $class => Data::Film
31 my $obj = $class->retrieve(1);
32  
33 =head1 DESCRIPTION
34  
35 See L<Class::DBI::Loader>, L<Class::DBI::Loader::Generic>.
36  
37 =cut
38  
39 0 ▶sub _db_class { return 'Class::DBI::Pg' }
Subroutine _db_class: not called CC=1 SCAR=6.9
40  
41 0 ▶sub _tables {
Subroutine _tables: not called CC=6 SCAR=37.4
42 0 my $self = shift;
43 0 ▶ my $dbh = DBI->connect( @{ $self->{_datasource} } ) or croak($DBI::errstr);
Branch: 1 branch
BranchTrueFalseTotal
my $dbh = "DBI"->connect(@{$$self{"_datasource"};}) or croak($DBI::errstr) 0 0 0
44  
45 # we do this check here because we don't really want to include this as
46 # a pre-requisite in the Makefile.PL for all those non-Pg users
47 0 my $sth = $dbh->prepare("SELECT version()");
48 0 $sth->execute();
49 0 my($vstr) = $sth->fetchrow_array();
50 0 $sth->finish;
51  
52 0 my($pg_version) = $vstr =~ /^PostgreSQL ([\d\.]{3})/;
53 0 ▶ if ($pg_version >= 8 && $Class::DBI::Pg::VERSION < 0.07) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pg_version >= 8 and $Class::DBI::Pg::VERSION < "0.07") 0 0 0
Condition0%0/3
$pg_version >= 8 and $Class::DBI::Pg::VERSION < "0.07"
!ll&&!rl&&r
000
MC/DC0%0/2
$pg_version >= 8 and $Class::DBI::Pg::VERSION < "0.07"
$pg_version >= 8 $Class::DBI::Pg::VERSION < "0.07"
Truth table0%0/3
A and B
A= $pg_version >= 8B= $Class::DBI::Pg::VERSION < "0.07"
ABresult
0X0
100
111
54 0 die "Class::DBI::Pg $Class::DBI::Pg::VERSION does not support PostgreSQL > 8.x";
55 }
56  
57 0 ▶ $self->{_namespace} ||= 'public';
Condition0%0/2
$self->{"_namespace"} ||= "public"
l!l
00
MC/DC0%0/1
$self->{"_namespace"} ||= "public"
$self->{"_namespace"}
Truth table0%0/2
A
A= $self->{"_namespace"}
Aresult
11
00
58 my @tables = ( $DBD::Pg::VERSION >= 1.31 ) ?
59 0 ▶ $dbh->tables( undef, $self->{_namespace}, "", "table",
Branch: 1 branch
BranchTrueFalseTotal
$DBD::Pg::VERSION >= 1.31 ? : 0 0 0
60 { noprefix => 1, pg_noprefix => 1 } ) :
61 $dbh->tables;
62  
63 0 @tables = map {s/^public:://;$_} @tables;
64 0 $dbh->disconnect;
65 0 return @tables;
66 }
67  
68 =head1 AUTHOR
69  
70 Daisuke Maki C<dmaki@cpan.org>
71 ( except for lines 62, 58, and 56 )
72  
73  
74 =head1 SEE ALSO
75  
76 L<Class::DBI::Loader>, L<Class::DBI::Loader::Generic>
77  
78 =cut
79  
80 2 1;
« Kinship.pm ↑ Summary