You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
This PR was recently merged to sqlx, which allows for Uuid support for the mysql driver. Not only can this encode/decode to the basic Uuid type, but we'd also included Hyphenated in there too: launchbadge/sqlx#536
This is especially helpful, because databases have a number of ways the UUID may be serialized back, e.g. the query may select hex-encoded hyphenated strings -- an increasingly common scenario, as these UUIDs may be pulled out of string fields, or stored json. We can encode + decode to a Hyphenated (or Simple, or Urn) easily enough, but it will force us to decode from a Hyphenated string if we ever want it as raw Bytes, even though those Bytes are already part of the struct.
Describe the solution you'd like
Any way to access the inner is fine. Not sure of the name -- a From<Hyphenated> for Uuid would be okay, as would .to_uuid(), .to_inner(), etc. I'd like it to keep to the style of the crate, hence why I'm opening an issue to ask for help instead of submitting a PR on this fairly simple change.
Is it blocking?
No. It's easy to work-around, just overly complex and poor performance.
Describe alternatives you've considered
I'd considered a a Deref or AsRef trait as a way to get a &Uuid that references the interior Bytes, if you want to avoid changing ownership of those Bytes, and it'd be easy enough to .to_owned or .clone that if you want. It'd also make it easy to write generics that take Deref<Target = Uuid> or AsRef<Uuid>, so you could pass a Uuid, Simple, Hyphenated, or Urn to them and they'd all work the same way. An Into<Uuid> would be nice for similar reasons. My point against this is that a [u8; 16] can Copy just fine, as it's only 2-words long.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
This PR was recently merged to sqlx, which allows for Uuid support for the mysql driver. Not only can this encode/decode to the basic Uuid type, but we'd also included Hyphenated in there too: launchbadge/sqlx#536
This is especially helpful, because databases have a number of ways the UUID may be serialized back, e.g. the query may select hex-encoded hyphenated strings -- an increasingly common scenario, as these UUIDs may be pulled out of string fields, or stored json. We can encode + decode to a Hyphenated (or Simple, or Urn) easily enough, but it will force us to decode from a Hyphenated string if we ever want it as raw Bytes, even though those Bytes are already part of the struct.
Describe the solution you'd like
Any way to access the inner is fine. Not sure of the name -- a
From<Hyphenated> for Uuid
would be okay, as would.to_uuid()
,.to_inner()
, etc. I'd like it to keep to the style of the crate, hence why I'm opening an issue to ask for help instead of submitting a PR on this fairly simple change.Is it blocking?
No. It's easy to work-around, just overly complex and poor performance.
Describe alternatives you've considered
I'd considered a a
Deref
orAsRef
trait as a way to get a&Uuid
that references the interior Bytes, if you want to avoid changing ownership of those Bytes, and it'd be easy enough to.to_owned
or.clone
that if you want. It'd also make it easy to write generics that takeDeref<Target = Uuid>
orAsRef<Uuid>
, so you could pass a Uuid, Simple, Hyphenated, or Urn to them and they'd all work the same way. AnInto<Uuid>
would be nice for similar reasons. My point against this is that a[u8; 16]
canCopy
just fine, as it's only 2-words long.The text was updated successfully, but these errors were encountered: