| 1 | package DBIx::ParseDSN::Default; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use v5.8.8; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use utf8::all; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use autodie; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use Carp qw< carp croak confess cluck >; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use DBI; # will use parse_dsn from here | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use version; our $VERSION = qv('0.9.3'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 8 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 8 | ▶ | use MooX::Aliases; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | ▶ | use MooX::HandlesVia; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 8 | has dsn => ( is => "ro", required => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 8 | has database => ( is => "rw", alias => [qw/db dbname/] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | has host => ( is => "rw", alias => "server" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | 8 | has port => ( is => "rw" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | 8 | has driver => ( is => "rw" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | 8 | has scheme => ( is => "rw", default => "dbi" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | has attr => ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | handles_via => "Hash", | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | is => "ro", | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 26 | ▶ | default => sub {{}}, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 8 | handles => { | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | set_attr => "set", | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | get_attr => "get", | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | delete_attr => "delete", | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | attributes => "elements", | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 38 | ▶ | around host => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 38 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 43 | 38 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 38 | ▶ | return $self->$orig unless my ($host) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 11 | $host =~ s/^tcp://; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 11 | ▶ | if ( $host =~ s/:(\d+)// ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | $self->port($1); | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 11 | return $self->$orig($host); | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 25 | ▶ | sub names_for_database { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names_for_database: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 25 | qw/database dbname name db/, | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | "sid", ## Oracle | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | "file name", "initialcatalog", ## from ADO, but generic | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ## enough to allow in this | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ## module | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 26 | ▶ | sub names_for_host { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names_for_host: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 26 | return qw/host hostname server/; | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 26 | ▶ | sub names_for_port { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names_for_port: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 26 | return qw/port/; | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 26 | ▶ | sub known_attribute_hash { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
known_attribute_hash: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 26 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | 26 | my %h; | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 26 | my @db_names = map { lc $_ } $self->names_for_database; | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 26 | @h{@db_names} = ("database") x @db_names; | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 26 | my @h_names = map { lc $_ } $self->names_for_host; | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | 26 | @h{@h_names} = ("host") x @h_names; | |||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 26 | my @p_names = map { lc $_ } $self->names_for_port; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | 26 | @h{@p_names} = ("port") x @p_names; | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 26 | return %h; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 106 | ▶ | sub dsn_parts { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dsn_parts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 106 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | 106 | return DBI->parse_dsn( $self->dsn ); | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 18 | ▶ | sub dbd_driver { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dbd_driver: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | 18 | my $driver = "DBD::" . $self->driver; | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | 18 | return $driver; | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 18 | ▶ | sub driver_attr { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
driver_attr: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | 18 | my ( $scheme, $driver, $attr, $attr_hash, $dsn ) = $self->dsn_parts; | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 18 | return $attr_hash; | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 44 | ▶ | sub driver_dsn { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
driver_dsn: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 44 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | 44 | return ($self->dsn_parts)[4]; | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 4 | ▶ | sub is_remote { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_remote: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | 4 | return not $self->is_local | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 6 | ▶ | sub is_local { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_local: called CC=5 SCAR=20.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | ## not much the default can do. if database exists as a file we | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | ## guess its a file based database and hence local | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 6 | ▶ | if ( defined $self->host and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
defined $self->host and lc $self->host eq "localhost" || $self->host eq "127.0.0.1"
lc $self->host eq "localhost" or $self->host eq "127.0.0.1"
MC/DC0%0/3
defined $self->host and lc $self->host eq "localhost" || $self->host eq "127.0.0.1"
defined $self->host
lc $self->host eq "localhost"
$self->host eq "127.0.0.1"
Truth table25%1/4
A and B or C
A= defined $self->hostB= lc $self->host eq "localhost"C= $self->host eq "127.0.0.1"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | lc $self->host eq "localhost" or | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | $self->host eq "127.0.0.1" | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | elsif ( -f $self->database ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 4 | confess "Cannot determine if db is local"; | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 26 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=15 SCAR=27.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | ## look for the following in the driver dsn: | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | ## 1: database: database dbname name db | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | ## 2: host: hostname host server | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | ## 3: port: port | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ## Assumes ";"-separated parameters in driver dsn | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | ## If driver dsn is one argument, its assumed to be the database | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 26 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 26 | $self->driver( ($self->dsn_parts)[1] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 26 | my @pairs = split /;/, $self->driver_dsn; | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 26 | my %known_attr = $self->known_attribute_hash; | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 26 | for (@pairs) { | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 46 | my($k,$v) = split /=/, $_, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ## An Oracle special case that would otherwise mess things up | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 46 | ▶ | if ( $self->driver eq "Oracle" and $k eq "SERVER" ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->driver eq "Oracle" and $k eq "SERVER"
MC/DC100%2/2
$self->driver eq "Oracle" and $k eq "SERVER"
$self->driver eq "Oracle"
$k eq "SERVER"
Truth table100%3/3
A and B
A= $self->driver eq "Oracle"B= $k eq "SERVER"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | ## example: SERVER=POOLED | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ## a //foo:xyz/bar type of uri, like Oracle | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 45 | ▶ | if ( $k =~ m|^//.+/.+| and not defined $v and @pairs == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
$k =~ m[^//.+/.+]u and not defined $v and @pairs == 1
$k =~ m[^//.+/.+]u and not defined $v
MC/DC33%1/3
$k =~ m[^//.+/.+]u and not defined $v and @pairs == 1
$k =~ m[^//.+/.+]u
not defined $v
@pairs == 1
Truth table50%2/4
A and not(B) and C
A= $k =~ m[^//.+/.+]uB= not defined $vC= @pairs == 1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | ## For this we offer something that works with oracle | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | my $u = URI->new; | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | $u->opaque($k); | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | my @p = $u->path_segments; | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | ## 2nd part of path is database | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | ▶ | if ( $p[1] ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | $self->database($p[1]); | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | ## host should be ok | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | ▶ | if ( my $host = $u->authority ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | ## might contain port | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | ▶ | if ( $host =~ s/:(\d+)// ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | $self->port($1); | |||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 2 | $self->host( $host ); | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | ▶ | elsif (not defined $v and @pairs == 1) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
not defined $v and @pairs == 1
MC/DC50%1/2
not defined $v and @pairs == 1
not defined $v
@pairs == 1
Truth table66%2/3
not(A) and B
A= not defined $vB= @pairs == 1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | $self->database($k); | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 45 | ▶ | if ( my $known_attr = $known_attr{lc $k} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 32 | $self->$known_attr( $v ); | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 45 | $self->set_attr($k, $v); | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | ## Another Oracle speciality, strip ":POOLED" from db | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 26 | ▶ | if ( $self->driver eq "Oracle" and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->driver eq "Oracle" and (my $new_db = $self->database) =~ s/:POOLED$//u
MC/DC100%2/2
$self->driver eq "Oracle" and (my $new_db = $self->database) =~ s/:POOLED$//u
$self->driver eq "Oracle"
(my $new_db = $self->database) =~ s/:POOLED$//u
Truth table100%3/3
A and B
A= $self->driver eq "Oracle"B= (my $new_db = $self->database) =~ s/:POOLED$//u
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | ( my $new_db = $self->database ) =~ s/:POOLED$// ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | $self->database($new_db); | |||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | ## intercept constructor to allow 1st arg DSN and 2nd arg user string, | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ## which may contain db name | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 27 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 27 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | 27 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 27 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | ## if first arg is a hash, work with that, otherwise start a new | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | ## empty hash | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 27 | ▶ | my %h = %{ ref $args[0] eq "HASH" ? $args[0] : {} }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | ## 1st arg can be dsn if not a hash | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 27 | ▶ | if ( defined $args[0] and ref $args[0] ne "HASH" ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $args[0] and ref $args[0] ne "HASH"
MC/DC50%1/2
defined $args[0] and ref $args[0] ne "HASH"
defined $args[0]
ref $args[0] ne "HASH"
Truth table66%2/3
A and B
A= defined $args[0]B= ref $args[0] ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 26 | $h{dsn} = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | ## look for db in user string - will not override one found in dsn | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 27 | ▶ | if ( defined $args[1] ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | ▶ | if ( $args[1] =~ /@(.+)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | (my $db = $1) =~ s|/.*||; | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | 2 | $h{database} = $db; | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 27 | return $class->$orig(\%h) | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 26 | ▶ | sub BUILD {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | ## call parse after build | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 26 | ▶ | after BUILD => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 26 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | 26 | $self->parse; | |||||||||||||||||||||||||||||||||||||||||||||
| 248 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 8 | 1; # Magic true value required at end of module | |||||||||||||||||||||||||||||||||||||||||||||
| 251 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||