Commit eb19bb99 authored by Magali Ruffier's avatar Magali Ruffier
Browse files

check stable ID version is always an integer

parent fb1b9dd7
Pipeline #189805 failed with stage
in 20 seconds
......@@ -151,7 +151,9 @@ sub fetch_by_stable_id {
# If we didn't get anything back, desperately try to see if there's
# a version number in the stable_id
if(!defined($arch_id) && (my $vindex = rindex($stable_id, '.'))) {
if(!defined($arch_id)) {
my $vindex = rindex($stable_id, '.');
if ($vindex !~ /[0-9]{1,5}/) { return $arch_id; }
$arch_id = $self->fetch_by_stable_id_version(substr($stable_id,0,$vindex),
substr($stable_id,$vindex+1),
@_);
......@@ -257,6 +259,10 @@ sub fetch_by_stable_id_version {
-version => $version,
-adaptor => $self
);
if ($version !~ /[0-9]{1,5}/) {
throw("$version is not valid, should be a small int");
}
@_ ? $arch_id->type(shift) : $self->_resolve_type($arch_id);
......
......@@ -23,6 +23,8 @@ use Test::Warnings;
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::DBSQL::ArchiveStableIdAdaptor;
use Bio::EnsEMBL::Test::TestUtils;
use Test::Exception;
use Test::Warnings qw(warning);
our $verbose = 0;
......@@ -51,6 +53,13 @@ is( $asi->release, 3, "T2 is from release 3");
$asi = $asia->fetch_by_stable_id_dbname("T1", "release_2");
is( $asi->release, 2, "T1 is from release 2");
#
# Check version is correct field
#
throws_ok { $asia->fetch_by_stable_id_version("T1", 'invalid_version') } qr/is not valid, should be a small int/, "version must be an integer";
warning { throws_ok { $asia->fetch_by_stable_id("T1.invalid_version") } qr/is not valid, should be a small int/, "Stable ID must have an integer as version" };
#
# 5 retrieval of an archiveStableId
......
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