finish up the databaseName method tests
This commit is contained in:
parent
6b2ed836fb
commit
3d016a366b
2 changed files with 46 additions and 19 deletions
|
|
@ -107,21 +107,22 @@ Based on the DSN, figures out what the database name is.
|
|||
=cut
|
||||
|
||||
sub databaseName {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
return $self->{_databaseName} if $self->{_databaseName};
|
||||
my @dsnEntries = split(/[:;]/, $self->get->{DSN});
|
||||
my @dsnEntries = split(/[:;]/, $self->get->{DSN});
|
||||
|
||||
my $databaseName;
|
||||
if ($dsnEntries[2] !~ /=/) {
|
||||
$databaseName = $dsnEntries[2];
|
||||
} else {
|
||||
foreach (@dsnEntries) {
|
||||
if ($_ =~ m/^(database|db|dbname)=(.+)$/) {
|
||||
$databaseName = $2;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($dsnEntries[2] !~ /=/) {
|
||||
$databaseName = $dsnEntries[2];
|
||||
}
|
||||
else {
|
||||
foreach (@dsnEntries) {
|
||||
if ($_ =~ m/^(?:database|db|dbname)=(.+)$/) {
|
||||
$databaseName = $1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $databaseName;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue