@@ -24,11 +24,12 @@ DB: $(hndl.db)
2424end
2525
2626struct MySQLInternalError <: MySQLError
27- ptr:: Ptr{Cvoid}
28- MySQLInternalError (con:: Connection ) = new (con. ptr)
29- MySQLInternalError (ptr) = new (ptr)
27+ errno:: Cuint
28+ msg:: String
29+ MySQLInternalError (con:: Connection ) = new (API. mysql_errno (con. ptr), unsafe_string (API. mysql_error (con. ptr)))
30+ MySQLInternalError (ptr) = new (API. mysql_errno (ptr), unsafe_string (API. mysql_error (ptr)))
3031end
31- Base. showerror (io:: IO , e:: MySQLInternalError ) = print (io, unsafe_string (API . mysql_error (e. ptr)) )
32+ Base. showerror (io:: IO , e:: MySQLInternalError ) = print (io, " ( $ (e. errno) ): $(e . msg) " )
3233
3334mutable struct Result
3435 ptr
@@ -54,9 +55,10 @@ mutable struct Query{hasresult, names, T}
5455 nrows:: Int
5556end
5657
57- function julia_type (field_type, nullable)
58+ function julia_type (field_type, nullable, isunsigned )
5859 T = API. julia_type (field_type)
59- return nullable ? Union{Missing, T} : T
60+ T2 = isunsigned ? unsigned (T) : T
61+ return nullable ? Union{Missing, T2} : T2
6062end
6163
6264function MySQLRowIterator (args... )
@@ -76,7 +78,7 @@ function Query(conn::Connection, sql::String; kwargs...)
7678 nrows = MySQL. API. mysql_num_rows (result. ptr)
7779 fields = MySQL. metadata (result. ptr)
7880 names = Tuple (ccall (:jl_symbol_n , Ref{Symbol}, (Ptr{UInt8}, Csize_t), x. name, x. name_length) for x in fields)
79- T = Tuple{(julia_type (x. field_type, API. nullable (x)) for x in fields). .. }
81+ T = Tuple{(julia_type (x. field_type, API. nullable (x), API . isunsigned (x) ) for x in fields). .. }
8082 hasresult = true
8183 ncols = length (fields)
8284 ptr = MySQL. API. mysql_fetch_row (result. ptr)
0 commit comments