Skip to content

Commit 1789a35

Browse files
committed
Looks like URI::db sets default port
1 parent 5116682 commit 1789a35

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lib/Mojo/mysql.pm

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package Mojo::mysql;
22
use Mojo::Base 'Mojo::EventEmitter';
33

4-
use Carp 'croak';
4+
use Carp qw(croak);
55
use DBI;
6-
use File::Spec::Functions 'file_name_is_absolute';
6+
use File::Spec::Functions qw(file_name_is_absolute);
77
use Mojo::mysql::Database;
88
use Mojo::mysql::Migrations;
99
use Mojo::URL;
10-
use Scalar::Util 'weaken';
10+
use Scalar::Util qw(blessed weaken);
1111
use SQL::Abstract::mysql;
1212

1313
use constant MARIADB => !!eval { require DBD::MariaDB; DBD::MariaDB->VERSION(1.21) };
@@ -68,14 +68,10 @@ sub from_string {
6868

6969
# Protocol
7070
return $self unless $str;
71-
my $url
72-
= UNIVERSAL::isa($str, 'URI::db') ? $str
73-
: UNIVERSAL::isa($str, 'Mojo::URL') ? $str
74-
: URI ? URI::db->new($str)
75-
: Mojo::URL->new($str);
71+
my $url = blessed $str ? $str : Mojo::URL->new($str);
7672

7773
my $protocol = $url->can('engine') ? $url->engine : $url->protocol;
78-
croak qq{"$str" must have the "mariadb" or "mysql" schemes} unless $protocol =~ m!^(mariadb|mysql)$!;
74+
croak qq{Invalid MySQL/MariaDB connection string "$str"} unless $protocol =~ m!^(mariadb|mysql)$!;
7975
my $dsn = $protocol eq 'mariadb' ? 'dbi:MariaDB' : 'dbi:mysql';
8076

8177
# Database

0 commit comments

Comments
 (0)