Commit fddb2428 authored by Andy Yates's avatar Andy Yates
Browse files

Edge case support for hive which allows for non-scheme URIs. We now treat...

Edge case support for hive which allows for non-scheme URIs. We now treat these as if they are DB URIs.
parent 2dda96d3
......@@ -70,7 +70,7 @@ our @EXPORT_OK;
sub parse_uri {
my ($url) = @_;
my $SCHEME = qr{ ([^:]+) :// }xms;
my $SCHEME = qr{ ([^:]*) :// }xms;
my $USER = qr{ ([^/:\@]+)? :? ([^/\@]+)? \@ }xms;
my $HOST = qr{ ([^/:]+)? :? ([^/]+)? }xms;
my $DB = qr{ / ([^/?]+)? /? ([^/?]+)? }xms;
......@@ -99,7 +99,7 @@ sub parse_uri {
$p->port($2);
}
if($p->is_db_scheme()) {
if($p->is_db_scheme() || $scheme eq q{}) {
if($locator =~ $DB) {
$p->db_params()->{dbname} = $1;
$p->db_params()->{table} = $2;
......@@ -131,7 +131,7 @@ sub parse_uri {
Arg[1] : String; scheme the URI will confrom to
Description : New object call
Returntype : Bio::EnsEMBL::Utils::URIParser::URI
Exceptions : None
Exceptions : Thrown if scheme is undefined.
Status : Stable
=cut
......@@ -139,7 +139,7 @@ sub parse_uri {
sub new {
my ($class, $scheme) = @_;
$class = ref($class) || $class;
throw "No scheme given" unless $scheme;
throw "Scheme cannot be undefined. Empty string is allowed" if ! defined $scheme;
my $self = bless ({
params => {},
......@@ -511,7 +511,7 @@ sub generate_uri {
);
}
if($self->is_db_scheme()) {
if($self->is_db_scheme() || $self->scheme() eq '') {
if($self->scheme() eq 'sqlite') {
if(! $self->path()) {
my $tmp_loc = $self->db_params()->{dbname};
......
......@@ -69,6 +69,12 @@ assert_db_parsing('URL with no user but a password','mysql://:pass@host:51/dbnam
-DBNAME => 'dbname'
});
assert_db_parsing('URL with no user but a password','mysql://:pass@host:51',{
-DRIVER => 'mysql',
-PASS => 'pass',
-HOST => 'host',
-PORT => 51
});
assert_db_parsing('URL no user credentials with table','mysql://host:51/dbname/table',{
-DRIVER => 'mysql',
......@@ -136,6 +142,14 @@ assert_db_parsing('URL params','mysql://host/db?param1=val1;param2',{
param2 => [undef]
});
#URI without a scheme
assert_parsing('URL no scheme',':////table',{
scheme => '',
db_params => { table => 'table', dbname => undef},
params => {},
param_keys => []
});
assert_parsing('http with params','http://host/path?param1=val1',{
scheme => 'http',
param_keys => [qw/param1/],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment