[Bps-public-commit] dbix-searchbuilder branch, quote-table-names, updated. 1.67-13-gd70dc92

Dianne Skoll dianne at bestpractical.com
Thu Dec 3 14:53:06 EST 2020


The branch, quote-table-names has been updated
       via  d70dc92d36f3cf60e4c53892f92bbf73006b23d8 (commit)
      from  7d20657706cb822f109a3250d4e2f294bfefc857 (commit)

Summary of changes:
 lib/DBIx/SearchBuilder/Handle/mysql.pm | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit d70dc92d36f3cf60e4c53892f92bbf73006b23d8
Author: Dianne Skoll <dianne at bestpractical.com>
Date:   Thu Dec 3 14:51:19 2020 -0500

    Fix bugs in version test to decide whether or not to quote table names for MySQL
    
    1) The test to detect MariaDB was incorrect since the return value
    from $self->DatabaseVersion would have chopped off the -MariaDB indicator.
    
    2) The test for DB version compared against 8 exactly instead of >= 8
    
    3) The test for DB version looked only at the first character of the
    version, which is fine for 8 or 9, but would fail for 10.

diff --git a/lib/DBIx/SearchBuilder/Handle/mysql.pm b/lib/DBIx/SearchBuilder/Handle/mysql.pm
index 97a042e..37ff3d6 100755
--- a/lib/DBIx/SearchBuilder/Handle/mysql.pm
+++ b/lib/DBIx/SearchBuilder/Handle/mysql.pm
@@ -309,13 +309,27 @@ sub QuoteName {
     return sprintf('`%s`', $name);
 }
 
+sub _IsMariaDB {
+    my $self = shift;
+
+    # We override DatabaseVersion to chop off "-MariaDB-whatever", so
+    # call super here to get the original version
+    my $v = $self->SUPER::DatabaseVersion();
+
+    return ($v =~ /mariadb/i);
+}
 
 sub _RequireQuotedTables {
     my $self = shift;
-    my $version = $self->DatabaseVersion;
+
     # MariaDB version does not match mysql, and hasn't added new reserved words
-    return 0 if ($version =~ m/mariadb/i);
-    if ( substr($version, 0, 1) == 8 ) {
+    return 0 if $self->_IsMariaDB;
+
+    my $version = $self->DatabaseVersion;
+
+    # Get major version number by chopping off everything after the first "."
+    $version =~ s/\..*//;
+    if ( $version >= 8 ) {
         return 1;
     }
     return 0;

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


More information about the Bps-public-commit mailing list