[Bps-public-commit] dbix-searchbuilder branch fix/mariadb-mysql-versions-check created. 1.74-1-g0468747

BPS Git Server git at git.bestpractical.com
Wed Apr 12 21:25:21 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "dbix-searchbuilder".

The branch, fix/mariadb-mysql-versions-check has been created
        at  046874702acb95d64a695f2f71bb024f9251230e (commit)

- Log -----------------------------------------------------------------
commit 046874702acb95d64a695f2f71bb024f9251230e
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Wed Apr 12 18:24:24 2023 -0300

    Fix database version comparison
    
    The version comparison was broken for MySQL and MariaDB because it was
    comparing versions as decimal numbers instead of dot bersions.

diff --git a/lib/DBIx/SearchBuilder/Handle.pm b/lib/DBIx/SearchBuilder/Handle.pm
index 7a25876..72b9f51 100755
--- a/lib/DBIx/SearchBuilder/Handle.pm
+++ b/lib/DBIx/SearchBuilder/Handle.pm
@@ -7,6 +7,7 @@ use Carp qw(croak cluck);
 use DBI;
 use Class::ReturnValue;
 use Encode qw();
+use version;
 
 use DBIx::SearchBuilder::Util qw/ sorted_values /;
 
@@ -335,7 +336,7 @@ sub Disconnect  {
 
     if (   $self->isa('DBIx::SearchBuilder::Handle::mysql')
         && $self->{'database_version'} =~ /mariadb/i
-        && $self->{'database_version'} ge '10.2' )
+        && version->parse('v'. $self->{'database_version'}) > version->parse('v10.2') )
     {
         $self->dbh(undef);
     }
diff --git a/lib/DBIx/SearchBuilder/Handle/mysql.pm b/lib/DBIx/SearchBuilder/Handle/mysql.pm
index b89db19..373a3cd 100755
--- a/lib/DBIx/SearchBuilder/Handle/mysql.pm
+++ b/lib/DBIx/SearchBuilder/Handle/mysql.pm
@@ -2,6 +2,7 @@ package DBIx::SearchBuilder::Handle::mysql;
 
 use strict;
 use warnings;
+use version;
 
 use base qw(DBIx::SearchBuilder::Handle);
 
@@ -364,10 +365,10 @@ sub HasSupportForCombineSearchAndCount {
     my ($version) = $self->DatabaseVersion =~ /^(\d+\.\d+)/;
 
     if ( $self->_IsMariaDB ) {
-        return $version >= 10.2 ? 1 : 0;
+        return (version->parse('v'.$version) >= version->parse('v'.10.2)) ? 1 : 0;
     }
     else {
-        return $version >= 8 ? 1 : 0;
+        return (version->parse('v'.$version) >= version->parse('v'.8)) ? 1 : 0;
     }
 }
 

-----------------------------------------------------------------------


hooks/post-receive
-- 
dbix-searchbuilder


More information about the Bps-public-commit mailing list