Skip to content

Commit 5124a5e

Browse files
authored
Don't call unsigned(T) for T <: AbstractFloat (#174)
* Add test that fails because of bug #173 * Remove unnecessary prepared stmt, add values inline * Don't call unsigned(T) if T <: AbstractFloat
1 parent a6afd18 commit 5124a5e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/MySQL.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ Base.isopen(conn::Connection) = API.isopen(conn.mysql)
302302

303303
function juliatype(field_type, notnullable, isunsigned, isbinary)
304304
T = API.juliatype(field_type)
305-
T2 = isunsigned ? unsigned(T) : T
305+
T2 = isunsigned && !(T <: AbstractFloat) ? unsigned(T) : T
306306
T3 = !isbinary && T2 == Vector{UInt8} ? String : T2
307307
return notnullable ? T3 : Union{Missing, T3}
308308
end

test/runtests.jl

+8
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,14 @@ ret = columntable(res)
279279
# multiple-queries not supported by mysql w/ prepared statements
280280
@test_throws MySQL.API.StmtError DBInterface.prepare(conn, "select * from Employee; select DeptNo, OfficeNo from Employee where OfficeNo IS NOT NULL")
281281

282+
# GitHub issue [#173](https://github.com/JuliaDatabases/MySQL.jl/issues/173)
283+
DBInterface.execute(conn, "DROP TABLE if exists unsigned_float")
284+
DBInterface.execute(conn, "CREATE TABLE unsigned_float(x FLOAT unsigned)")
285+
DBInterface.execute(conn, "INSERT INTO unsigned_float VALUES (1.1), (1.2)")
286+
res = DBInterface.execute(conn, "select x from unsigned_float") |> columntable
287+
@test res.x == Vector{Float32}([1.1, 1.2])
288+
# end issue #173
289+
282290
# 156
283291
res = DBInterface.execute(conn, "select * from Employee")
284292
DBInterface.close!(conn)

0 commit comments

Comments
 (0)