jhthorsen / mojo-mysql

Mojolicious and Async MySQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Warning caused when using DBD::MariaDB and setting mysql_auto_reconnect to false

srchulo opened this issue · comments

This line:

https://github.com/jhthorsen/mojo-mysql/blob/master/lib/Mojo/mysql.pm#L115

Causes this warning:

DBD::MariaDB::db STORE failed: Unknown attribute mysql_auto_reconnect at /home/jhthorsen/perl5/perlbrew/perls/perl-5.28.0/lib/site_perl/5.28.0/Mojo/mysql.pm line 115.

When using the https://metacpan.org/pod/DBD::MariaDB driver instead of https://metacpan.org/pod/DBD::mysql.

mariadb_auto_reconnect is set to false by default, but If you still wanted to set that, maybe set that instead of mysql_auto_reconnect when using the DBD::MariaDB driver?

commented

A couple lines above that it should be setting it to mariadb_auto_reconnect (and this is only because it is forcing it off in case the user turned it on). Somehow you are getting it to use DBD::MariaDB but with a dbi:mysql DSN. How are you setting up the object?

Ah, it seems like the warning occurs if I build my own DSN:

my $mysql = Mojo::mysql->new(dsn => 'DBI:MariaDB:database=db;host=localhost;port=3306;', username => 'user', password => 'pass');

But doesn't occur if I use this format:

my $mysql = Mojo::mysql->new('mariadb://user:password@localhost/db');

commented

my $mysql = Mojo::mysql->new(dsn => 'DBI:MariaDB:database=db;host=localhost;port=3306;', username => 'user', password => 'pass');

And if you write dbi:MariaDB:database=db;host=localhost;port=3306?
From the DBI docs: "$scheme is the first part of the DSN and is currently always 'dbi'."

Ah, that solves it. My mistake! Thanks :)