Skip to content

Commit eca52e7

Browse files
committed
Couple bugfixes
1 parent 3968588 commit eca52e7

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/api.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct MYSQL_FIELD
4545
field_type::Cuint ## Type of field. See mysql_com.h for types
4646
extension::Ptr{Cvoid}
4747
end
48-
nullable(field) = (field.flags & API.NOT_NULL_FLAG) > 0
48+
notnullable(field) = (field.flags & API.NOT_NULL_FLAG) > 0
4949
isunsigned(field) = (field.flags & API.UNSIGNED_FLAG) > 0
5050

5151
"""

src/consts.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct Bit
3535
bits::UInt64
3636
end
3737
Base.show(io::IO, b::Bit) = print(io, "MySQL.API.Bit(\"$(lstrip(bitstring(b.bits), '0'))\")")
38+
Base.unsigned(::Type{Bit}) = Bit
3839

3940
mysql_type(::Type{Bit}) = MYSQL_TYPE_BIT
4041
mysql_type(::Type{Cchar}) = MYSQL_TYPE_TINY

src/types.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ mutable struct Query{hasresult, names, T}
5555
nrows::Int
5656
end
5757

58-
function julia_type(field_type, nullable, isunsigned)
58+
function julia_type(field_type, notnullable, isunsigned)
5959
T = API.julia_type(field_type)
6060
T2 = isunsigned ? unsigned(T) : T
61-
return nullable ? Union{Missing, T2} : T2
61+
return notnullable ? T2 : Union{Missing, T2}
6262
end
6363

6464
function MySQLRowIterator(args...)
@@ -78,7 +78,7 @@ function Query(conn::Connection, sql::String; kwargs...)
7878
nrows = MySQL.API.mysql_num_rows(result.ptr)
7979
fields = MySQL.metadata(result.ptr)
8080
names = Tuple(ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Csize_t), x.name, x.name_length) for x in fields)
81-
T = Tuple{(julia_type(x.field_type, API.nullable(x), API.isunsigned(x)) for x in fields)...}
81+
T = Tuple{(julia_type(x.field_type, API.notnullable(x), API.isunsigned(x)) for x in fields)...}
8282
hasresult = true
8383
ncols = length(fields)
8484
ptr = MySQL.API.mysql_fetch_row(result.ptr)

0 commit comments

Comments
 (0)