-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Uuid support for MySQL #536
Conversation
This is a good start. Each Rust type needs to pick one SQL type if the format we encode to is different. The Why don't we implement Type as One more thing, Here is an example of using trait delegation to re-use the impl for impl Decode<'_, MySql> for Uuid {
fn decode(value: MySqlValueRef<'_>) -> Result<Self, BoxDynError> {
// delegate to the &[u8] type to decode from MySQL
let bytes = <&[u8] as Decode<MySql>>::decode(value)?;
// construct a Uuid from the returned bytes
Uuid::from_slice(bytes).map_err(Into::into)
}
} |
@mehcode so that sounds right to me -- where do those BINARY and CHAR types get defined? |
@mehcode Alright we've put in support for |
While there's no native UUID type in mysql, we can use either the standard hex-encoded string, or a raw
BYTES(16)
to represent a UUID.I think this may still need some more type data setup. The
Encode
also assumes a binary encoding, but mysql aggregate functions exist to support both the 128-bit encoding, and the hex-encoded string with the dashes, so we ought to be able to encode to both somehow: https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid .