-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
values of UInt8 data types get converted to 125 #70
Comments
It doesn't appear that create table tbl (
col tinyint,
col2 unsigned tinyint
); results in an error like:
Could you verify that the above query works in your version of MySQL? If so, which version of MySQL are you running? |
nah it doesn't, wtf |
@dscottboggs
|
Oh, I see, my bad. SQL is not my best language... thanks for your help |
Ok so I played around with implementing this a bit, and I don't see any way to store an unsigned integer via the interface provided to Crystal. See the documentation for basic types and for response value types in the binary interface. Neither offer any means of differentiating between I recommend we add some error checking which simply says "use the next size bigger signed values, unsigned values don't work" but otherwise leave things as they are. If that's ok I'll submit a PR as soon as I get the chance. |
There must be a flag in the protocol that reports the integer value as unsigned, and it's probably not supported/overlooked by the current implementation. One should dig the MySQL protocol documentation, implement support and declare the UIntX encoder/decoder types. |
thanks for your time, @ysbaddaden. i did some digging, and found: would this help? |
The fixed and and length encoded integers are implemented in Nevertheless the mapping from the types of the database to the types in crystal is in Maybe the sign information comes in the column definition and that should be used somewhere. Ref: When reading values there needs to be two implementation one for binary protocol (prepared statements) and one for text protocol (non prepared statements). The lack of UInt support is probably a consequence of trying to favor Int for general purpose and leaving UInt for protocol things. That is why A PR is welcome as long as a The great reference for protocol implementation can be found in https://dev.mysql.com/doc/internals/en/ |
Ran into this little quirk today. i checked with gitter, and pretty sure it's a bug, not entirely sure though
query:
storage type in mysql, set as tinyint, 255, unsigned
if you don't set the length to 255, but keep it unsigned, it will give you a read error:
if you set the length to 255, that error is gone. however, now your value gets converted to 125
thanks for reading! special thanks to @dscottboggs_gitlab in gitter for the help
The text was updated successfully, but these errors were encountered: