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

BPS Git Server git at git.bestpractical.com
Fri Apr 14 17:49:06 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  e62e70e4fc0ca8c677d533e6ac8d40464950dda3 (commit)

- Log -----------------------------------------------------------------
commit e62e70e4fc0ca8c677d533e6ac8d40464950dda3
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..ebec957 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 /;
 
@@ -332,10 +333,10 @@ sub Disconnect  {
     # interacting with a disconnected handle, here we unset
     # dbh to inform other code that there is no connection any more.
     # See also https://github.com/perl5-dbi/DBD-mysql/issues/306
-
+    my ($version) = $self->{'database_version'} =~ /^(\d+\.\d+)/;
     if (   $self->isa('DBIx::SearchBuilder::Handle::mysql')
         && $self->{'database_version'} =~ /mariadb/i
-        && $self->{'database_version'} ge '10.2' )
+        && version->parse('v'.$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..17b353a 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('v10.2')) ? 1 : 0;
     }
     else {
-        return $version >= 8 ? 1 : 0;
+        return (version->parse('v'.$version) >= version->parse('v8')) ? 1 : 0;
     }
 }
 

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


hooks/post-receive
-- 
dbix-searchbuilder


More information about the Bps-public-commit mailing list