-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support unsigned integer #618
Changes from 1 commit
a08e174
ae2f56a
8fecffb
9d69d8e
e938863
c4d1470
27c385e
aacf93b
1ed3e45
d6aed81
e219ad1
f296c6b
5eb03e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,22 @@ object CanBeParameter { | |
new CanBeParameter[BigInt] { | ||
def sizeOf(param: BigInt) = 8 | ||
def typeCode(param: BigInt) = Type.LongLong | ||
def write(writer: MysqlBufWriter, param: BigInt) = writer.writeBytes(param.toByteArray) | ||
def write(writer: MysqlBufWriter, param: BigInt) = { | ||
val byteArray: Array[Byte] = param.toByteArray | ||
val lengthOfByteArray: Int = byteArray.length | ||
|
||
if (lengthOfByteArray > 8) { | ||
throw new Exception(s"The length of BigInt is larger than 8 bytes: $lengthOfByteArray > 8") | ||
} | ||
|
||
for (i <- 0 until lengthOfByteArray) { | ||
writer.writeByte(byteArray(i)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to reverse the order of the bytes we read out of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, sorry I should have checked that - sending the fix. |
||
} | ||
|
||
for (i <- lengthOfByteArray until 8) { | ||
writer.writeByte(0x0) | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create a new named exception for this (can define it somehwere in the file here). I suggest something like:
class BigIntTooLongException(size: Int) extends Exception(s"BigInt is stored as an unsigned long and thus cannot be grater than 8 bytes. Size: $size"