Skip to content

Commit ce1f9fc

Browse files
authored
Ignore any host url protocol that includes "mysql://" (#179)
Fixes #170. As far as I can tell, certain projects suggest/require using "mysql://", "mysqlx://", "jdbc:mysql://", etc. as the protocol portion of the host url. This ends up with really weird behavior in MySQL.jl because it assumes there's a plugin that needs to be loaded. So the fix here is just a simple check if "mysql://" is in the host url and if so, only use the rest of the string after it.
1 parent 2da4c33 commit ce1f9fc

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/MySQL.jl

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ mutable struct Connection <: DBInterface.Connection
2727
API.setoption(mysql, API.MYSQL_SET_CHARSET_NAME, "utf8mb4")
2828
client_flag = clientflags(; kw...)
2929
setoptions!(mysql; kw...)
30+
rng = findfirst("mysql://", host)
31+
if rng !== nothing
32+
host = host[last(rng)+1:end]
33+
end
3034
mysql = API.connect(mysql, host, user, passwd, db, port, unix_socket, client_flag)
3135
return new(mysql, host, user, string(port), db, nothing)
3236
end

test/runtests.jl

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ using Test, MySQL, DBInterface, Tables, Dates, DecFP
33
conn = DBInterface.connect(MySQL.Connection, "127.0.0.1", "root", ""; port=3306)
44
DBInterface.close!(conn)
55

6+
# https://github.com/JuliaDatabases/MySQL.jl/issues/170
7+
conn = DBInterface.connect(MySQL.Connection, "mysql://127.0.0.1", "root", ""; port=3306)
8+
DBInterface.close!(conn)
9+
610
# load host/user + options from file
711
conn = DBInterface.connect(MySQL.Connection, "", "", ""; option_file="my.ini")
812
@test isopen(conn)

0 commit comments

Comments
 (0)