]> git.donarmstrong.com Git - infobot.git/commitdiff
enable utf8mb4 for mysql
authorDon Armstrong <don@donarmstrong.com>
Fri, 29 Dec 2017 22:36:39 +0000 (14:36 -0800)
committerDon Armstrong <don@donarmstrong.com>
Fri, 29 Dec 2017 22:36:39 +0000 (14:36 -0800)
src/dbi.pl

index 09a79189476c5fa8f64e4df050fdc31fc54d1fc6..3e4bf82b174456e578e3a088d6912cbbc5480fcc 100644 (file)
@@ -74,6 +74,7 @@ eval {
 sub sqlOpenDB {
     my ( $db, $type, $user, $pass, $no_fail ) = @_;
 
+    my $attr = {};
     # this is a mess. someone fix it, please.
     if ( $type =~ /^SQLite(2)?$/i ) {
         $db = "dbname=$db.sqlite";
@@ -82,6 +83,9 @@ sub sqlOpenDB {
         $db   = "dbname=$db";
         $type = 'Pg';
     }
+    elsif ($type =~ /mysql/) {
+        $attr->{mysql_enable_utf8mb4} = 1;
+    }
 
     my $dsn     = "DBI:$type:$db";
     my $hoststr = '';
@@ -100,7 +104,7 @@ sub sqlOpenDB {
     }
 
     # SQLite ignores $user and $pass
-    $dbh = Bloot::DBI->new( DBI->connect( $dsn, $user, $pass ) );
+    $dbh = Bloot::DBI->new( DBI->connect( $dsn, $user, $pass, $attr ) );
 
     if ( $dbh && !$dbh->err ) {
         &status("Opened $type connection$hoststr");