Skip to content

Commit 87dc389

Browse files
authored
Check whether column is numeric along with unsigned check (#163)
Attempt to fix #159. It seems there are cases when `API.isunsigned` will return true for a timestamp column; this is probably due to some kind of database or column setting when the table was created, but nonetheless, it causes issues because if `API.isunsigned`, then we try to call `unsigned(T)`, which isn't defined for `DateTime`. As opposed to pirating that definition in MySQL.jl, here we attempt to also check the `NUM_FLAG`, which should tell us whether the field is numeric or not and hopefully avoid ever seeing `API.isunsigned` for timestamp columns.
1 parent 731f39c commit 87dc389

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/api/apitypes.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ struct MYSQL_FIELD
8989
extension::Ptr{Cvoid}
9090
end
9191
notnullable(field) = (field.flags & NOT_NULL_FLAG) > 0
92-
isunsigned(field) = (field.flags & UNSIGNED_FLAG) > 0
92+
isunsigned(field) = (field.flags & NUM_FLAG) > 0 && (field.flags & UNSIGNED_FLAG) > 0
9393
isbinary(field) = (field.flags & BINARY_FLAG) > 0
9494

9595
const MYSQL_FIELD_OFFSET = Cuint

src/api/consts.jl

+1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ const MYSQL_TIMESTAMP_TIME = 2
206206
const NOT_NULL_FLAG = UInt32(1)
207207
const UNSIGNED_FLAG = UInt32(32)
208208
const BINARY_FLAG = UInt32(128)
209+
const NUM_FLAG = UInt32(32768)
209210
const MYSQL_NO_DATA = 100
210211

211212
const MYSQL_DEFAULT_PORT = 3306

0 commit comments

Comments
 (0)