From: Peter Rabbitson Date: Thu, 8 Apr 2010 10:56:33 +0000 (+0000) Subject: Even safer version normalization X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a8f3649170443a06b886bede78f4abeefafe52ed;p=dbsrgits%2FDBIx-Class-Historic.git Even safer version normalization --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 655f506..f24a9e1 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -950,11 +950,18 @@ sub _server_info { if ( @verparts && - @verparts <= 3 - && - ! grep { $_ > 999 } (@verparts) + $verparts[0] <= 999 ) { - $info{normalized_dbms_version} = sprintf "%d.%03d%03d", @verparts; + # consider only up to 3 version parts, iff not more than 3 digits + my @use_parts; + while (@verparts && @use_parts < 3) { + my $p = shift @verparts; + last if $p > 999; + push @use_parts, $p; + } + push @use_parts, 0 while @use_parts < 3; + + $info{normalized_dbms_version} = sprintf "%d.%03d%03d", @use_parts; } }