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

Timestamp and unsigned(DateTime) #159

Closed
hrhill opened this issue May 15, 2020 · 2 comments · Fixed by #163
Closed

Timestamp and unsigned(DateTime) #159

hrhill opened this issue May 15, 2020 · 2 comments · Fixed by #163

Comments

@hrhill
Copy link

hrhill commented May 15, 2020

Running the test suite of 1.04 on Julia 1.4.1 on linux gave me the following error,

ERROR: LoadError: MethodError: no method matching zero(::Type{DateTime})
Closest candidates are:
  zero(::Type{Missing}) at missing.jl:103
  ...
  ...
Stacktrace:
 [1] unsigned(::Type{T} where T) at ./int.jl:158
 [2] juliatype(::UInt32, ::Bool, ::Bool, ::Bool) at /home/harry/repos/MySQL.jl/src/MySQL.jl:274
 [3] execute(::MySQL.Connection, ::String, ::Tuple{}; mysql_store_result::Bool) at /home/harry/repos/MySQL.jl/src/execute.jl:162
 [4] execute at /home/harry/repos/MySQL.jl/src/execute.jl:133 [inlined] (repeats 2 times)
 [5] top-level scope at /home/harry/repos/MySQL.jl/test/runtests.jl:62
 [6] include(::String) at ./client.jl:439
 [7] top-level scope at none:6

API.isunsigned returns true for the timestamp field, and the error comes from this line

L247    T2 = isunsigned ? unsigned(T) : T

Not sure what the right fix is - should zero(DateTime) be something valid? Anyway, putting this in MySQL.jl got the tests pass, but not sure if that's the right approach.

import Base.unsigned
unsigned(::Type{DateTime}) = DateTime
quinnj added a commit that referenced this issue Jun 1, 2020
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.
quinnj added a commit that referenced this issue Jun 1, 2020
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.
@quinnj
Copy link
Member

quinnj commented Jun 1, 2020

Thanks for reporting! I merged a fix for this to master; could you try it out and see if that fixes it for you?

@hrhill
Copy link
Author

hrhill commented Jun 2, 2020

Yes, all good now, thank you!

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

Successfully merging a pull request may close this issue.

2 participants