Skip to content

Commit

Permalink
Check whether column is numeric along with unsigned check (#163)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
quinnj authored Jun 1, 2020
1 parent 731f39c commit 87dc389
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/api/apitypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct MYSQL_FIELD
extension::Ptr{Cvoid}
end
notnullable(field) = (field.flags & NOT_NULL_FLAG) > 0
isunsigned(field) = (field.flags & UNSIGNED_FLAG) > 0
isunsigned(field) = (field.flags & NUM_FLAG) > 0 && (field.flags & UNSIGNED_FLAG) > 0
isbinary(field) = (field.flags & BINARY_FLAG) > 0

const MYSQL_FIELD_OFFSET = Cuint
Expand Down
1 change: 1 addition & 0 deletions src/api/consts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ const MYSQL_TIMESTAMP_TIME = 2
const NOT_NULL_FLAG = UInt32(1)
const UNSIGNED_FLAG = UInt32(32)
const BINARY_FLAG = UInt32(128)
const NUM_FLAG = UInt32(32768)
const MYSQL_NO_DATA = 100

const MYSQL_DEFAULT_PORT = 3306
Expand Down

0 comments on commit 87dc389

Please sign in to comment.