Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MariaDB version 11 is incompatible with MySQL - String columns are detected as Dec64 #208

Open
hhaensel opened this issue Jul 25, 2023 · 1 comment

Comments

@hhaensel
Copy link

column types are not correctly inferred when updating mariadb to version 11.
It's probably worthwhile switching to the latest mariadb c connector
with MariaDB Server 10:

julia> DataFrame(DBInterface.execute(conn, "select * from `benutzer`"))
2×1 DataFrame
 Row │ uname
     │ String?
─────┼─────────
   1 │ test
   2 │ rest

with MariaDB Server 11:

julia> DBInterface.execute(conn, "select * from `benutzer`") |> DataFrame
ERROR: ArgumentError: invalid number format test
Stacktrace:
  [1] parse(#unused#::Type{DecFP.Dec64}, s::String)
    @ DecFP C:\Users\helmu\.julia\packages\DecFP\Cud5F\src\DecFP.jl:323

If I store strings that can be parsed as numbers in the field 'uname' the columns are indeed read as Dec64.

julia> DataFrame(hh)
3×1 DataFrame
 Row │ uname
     │ Dec64
─────┼───────
   110.0
   211.0
   314.0

This behaviour is consistent with the (wrong) column type stored in the query result:

julia> res = DBInterface.execute(conn, "select * from `benutzer`");

julia> res.types
1-element Vector{Type}:
 Union{Missing, DecFP.Dec64}
@pascalr0410
Copy link
Contributor

Hello,

Same here, must fall back on branch 10 of MariaDb.

The C Lib used seems quite old, released in December. 2019.

In fact, after some debugging, the library returns a zero in field_type, causing it to be misinterpreted as Dec64

/src/MySQL.jl

# --> Here, the real type is VARCHAR

function juliatype(field_type, notnullable, isunsigned, isbinary, date_and_time)
    @info field_type # --> 0
    T = API.juliatype(field_type)
    @info T # --> Dec64
    T2 = isunsigned && !(T <: AbstractFloat) ? unsigned(T) : T
    T3 = !isbinary && T2 == Vector{UInt8} ? String : T2
    T4 = date_and_time && T3 <: DateTime ? DateAndTime : T3
    return notnullable ? T4 : Union{Missing, T4}
end

Regards,
Pascal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants